瀏覽代碼

Fixes stuck progress on the Graph (again!!)

main
Eric Amodio 2 年之前
父節點
當前提交
6adbeefb99
共有 4 個檔案被更改,包括 17 行新增23 行删除
  1. +1
    -0
      src/plus/webviews/graph/graphWebview.ts
  2. +2
    -1
      src/plus/webviews/graph/protocol.ts
  3. +4
    -6
      src/webviews/apps/plus/graph/GraphWrapper.tsx
  4. +10
    -16
      src/webviews/apps/plus/graph/graph.tsx

+ 1
- 0
src/plus/webviews/graph/graphWebview.ts 查看文件

@ -569,6 +569,7 @@ export class GraphWebview extends WebviewBase {
subscription: access.subscription.current,
allowed: access.allowed,
avatars: data != null ? Object.fromEntries(data.avatars) : undefined,
loading: deferRows,
rows: data?.rows,
paging:
data != null

+ 2
- 1
src/plus/webviews/graph/protocol.ts 查看文件

@ -13,6 +13,7 @@ export interface State {
subscription?: Subscription;
allowed: boolean;
avatars?: { [email: string]: string };
loading?: boolean;
rows?: GraphRow[];
paging?: GraphPaging;
config?: GraphCompositeConfig;
@ -60,7 +61,7 @@ export interface GraphCompositeConfig extends GraphConfig {
}
export interface UpdateStateCallback {
(state: State, previousRowCount: number | undefined): void;
(state: State): void;
}
// Commands

+ 4
- 6
src/webviews/apps/plus/graph/GraphWrapper.tsx 查看文件

@ -143,6 +143,7 @@ export function GraphWrapper({
allowed,
avatars,
config,
loading,
paging,
onSelectRepository,
onColumnChange,
@ -164,7 +165,7 @@ export function GraphWrapper({
const [graphSelectedRows, setSelectedRows] = useState(selectedRows);
const [graphColSettings, setGraphColSettings] = useState(getGraphColSettingsModel(config));
const [pagingState, setPagingState] = useState(paging);
const [isLoading, setIsLoading] = useState(true);
const [isLoading, setIsLoading] = useState(loading);
const [styleProps, setStyleProps] = useState(getStyleProps(mixedColumnColors));
// TODO: application shouldn't know about the graph component's header
const graphHeaderOffset = 24;
@ -197,7 +198,7 @@ export function GraphWrapper({
return () => resizeObserver.disconnect();
}, [mainRef]);
function transformData(state: State, previousRowCount: number | undefined) {
function transformData(state: State) {
setGraphRows(state.rows ?? []);
setAvatars(state.avatars ?? {});
setReposList(state.repositories ?? []);
@ -210,10 +211,7 @@ export function GraphWrapper({
setShowAccount(state.trialBanner ?? true);
setSubscriptionSnapshot(state.subscription);
setIsPrivateRepo(state.selectedRepositoryVisibility === RepositoryVisibility.Private);
if (!isLoading || previousRowCount !== state.rows?.length || previousRowCount == null) {
setIsLoading(state.rows == null);
}
setIsLoading(state.loading);
}
useEffect(() => subscriber?.(transformData), []);

+ 10
- 16
src/webviews/apps/plus/graph/graph.tsx 查看文件

@ -96,17 +96,15 @@ export class GraphApp extends App {
switch (msg.method) {
case DidChangeNotificationType.method:
onIpc(DidChangeNotificationType, msg, params => {
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, ...params.state });
this.refresh(this.state, previousRowCount);
this.refresh(this.state);
});
break;
case DidChangeAvatarsNotificationType.method:
onIpc(DidChangeAvatarsNotificationType, msg, params => {
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, avatars: params.avatars });
this.refresh(this.state, previousRowCount);
this.refresh(this.state);
});
break;
@ -173,42 +171,39 @@ export class GraphApp extends App {
}
}
const previousRowCount = this.state.rows?.length;
this.setState({
...this.state,
avatars: params.avatars,
rows: rows,
loading: false,
paging: params.paging,
});
this.refresh(this.state, previousRowCount);
this.refresh(this.state);
});
break;
case DidChangeSelectionNotificationType.method:
onIpc(DidChangeSelectionNotificationType, msg, params => {
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, selectedRows: params.selection });
this.refresh(this.state, previousRowCount);
this.refresh(this.state);
});
break;
case DidChangeGraphConfigurationNotificationType.method:
onIpc(DidChangeGraphConfigurationNotificationType, msg, params => {
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, config: params.config });
this.refresh(this.state, previousRowCount);
this.refresh(this.state);
});
break;
case DidChangeSubscriptionNotificationType.method:
onIpc(DidChangeSubscriptionNotificationType, msg, params => {
const previousRowCount = this.state.rows?.length;
this.setState({
...this.state,
subscription: params.subscription,
allowed: params.allowed,
});
this.refresh(this.state, previousRowCount);
this.refresh(this.state);
});
break;
@ -218,9 +213,8 @@ export class GraphApp extends App {
}
protected override onThemeUpdated() {
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, mixedColumnColors: undefined });
this.refresh(this.state, previousRowCount);
this.refresh(this.state);
}
protected override setState(state: State) {
@ -297,8 +291,8 @@ export class GraphApp extends App {
};
}
private refresh(state: State, previousRowCount: number | undefined) {
this.callback?.(state, previousRowCount);
private refresh(state: State) {
this.callback?.(state);
}
}

Loading…
取消
儲存