Browse Source

Fixes stuck progress indicators on the Graph

main
Eric Amodio 2 years ago
parent
commit
4eb17cc340
3 changed files with 21 additions and 20 deletions
  1. +1
    -1
      src/plus/webviews/graph/protocol.ts
  2. +4
    -2
      src/webviews/apps/plus/graph/GraphWrapper.tsx
  3. +16
    -17
      src/webviews/apps/plus/graph/graph.tsx

+ 1
- 1
src/plus/webviews/graph/protocol.ts View File

@ -60,7 +60,7 @@ export interface GraphCompositeConfig extends GraphConfig {
} }
export interface UpdateStateCallback { export interface UpdateStateCallback {
(state: State, oldState: State): void;
(state: State, previousRowCount: number | undefined): void;
} }
// Commands // Commands

+ 4
- 2
src/webviews/apps/plus/graph/GraphWrapper.tsx View File

@ -197,9 +197,11 @@ export function GraphWrapper({
return () => resizeObserver.disconnect(); return () => resizeObserver.disconnect();
}, [mainRef]); }, [mainRef]);
function transformData(state: State, oldState: State) {
if (!isLoading || oldState.rows !== state.rows) {
function transformData(state: State, previousRowCount: number | undefined) {
if (!isLoading || previousRowCount !== state.rows?.length) {
setIsLoading(state.rows == null); setIsLoading(state.rows == null);
} else {
setIsLoading(false);
} }
setGraphRows(state.rows ?? []); setGraphRows(state.rows ?? []);

+ 16
- 17
src/webviews/apps/plus/graph/graph.tsx View File

@ -96,17 +96,17 @@ export class GraphApp extends App {
switch (msg.method) { switch (msg.method) {
case DidChangeNotificationType.method: case DidChangeNotificationType.method:
onIpc(DidChangeNotificationType, msg, params => { onIpc(DidChangeNotificationType, msg, params => {
const old = this.state;
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, ...params.state }); this.setState({ ...this.state, ...params.state });
this.refresh(this.state, old);
this.refresh(this.state, previousRowCount);
}); });
break; break;
case DidChangeAvatarsNotificationType.method: case DidChangeAvatarsNotificationType.method:
onIpc(DidChangeAvatarsNotificationType, msg, params => { onIpc(DidChangeAvatarsNotificationType, msg, params => {
const old = this.state;
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, avatars: params.avatars }); this.setState({ ...this.state, avatars: params.avatars });
this.refresh(this.state, old);
this.refresh(this.state, previousRowCount);
}); });
break; break;
@ -169,47 +169,46 @@ export class GraphApp extends App {
if (params.rows.length === 0) { if (params.rows.length === 0) {
rows = this.state.rows; rows = this.state.rows;
} else { } else {
// TODO@eamodio I'm not sure there is a case for this, but didn't wan't to remove it yet
rows = params.rows; rows = params.rows;
} }
} }
const old = this.state;
const previousRowCount = this.state.rows?.length;
this.setState({ this.setState({
...this.state, ...this.state,
avatars: params.avatars, avatars: params.avatars,
rows: rows, rows: rows,
paging: params.paging, paging: params.paging,
}); });
this.refresh(this.state, old);
this.refresh(this.state, previousRowCount);
}); });
break; break;
case DidChangeSelectionNotificationType.method: case DidChangeSelectionNotificationType.method:
onIpc(DidChangeSelectionNotificationType, msg, params => { onIpc(DidChangeSelectionNotificationType, msg, params => {
const old = this.state;
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, selectedRows: params.selection }); this.setState({ ...this.state, selectedRows: params.selection });
this.refresh(this.state, old);
this.refresh(this.state, previousRowCount);
}); });
break; break;
case DidChangeGraphConfigurationNotificationType.method: case DidChangeGraphConfigurationNotificationType.method:
onIpc(DidChangeGraphConfigurationNotificationType, msg, params => { onIpc(DidChangeGraphConfigurationNotificationType, msg, params => {
const old = this.state;
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, config: params.config }); this.setState({ ...this.state, config: params.config });
this.refresh(this.state, old);
this.refresh(this.state, previousRowCount);
}); });
break; break;
case DidChangeSubscriptionNotificationType.method: case DidChangeSubscriptionNotificationType.method:
onIpc(DidChangeSubscriptionNotificationType, msg, params => { onIpc(DidChangeSubscriptionNotificationType, msg, params => {
const old = this.state;
const previousRowCount = this.state.rows?.length;
this.setState({ this.setState({
...this.state, ...this.state,
subscription: params.subscription, subscription: params.subscription,
allowed: params.allowed, allowed: params.allowed,
}); });
this.refresh(this.state, old);
this.refresh(this.state, previousRowCount);
}); });
break; break;
@ -219,9 +218,9 @@ export class GraphApp extends App {
} }
protected override onThemeUpdated() { protected override onThemeUpdated() {
const old = this.state;
const previousRowCount = this.state.rows?.length;
this.setState({ ...this.state, mixedColumnColors: undefined }); this.setState({ ...this.state, mixedColumnColors: undefined });
this.refresh(this.state, old);
this.refresh(this.state, previousRowCount);
} }
protected override setState(state: State) { protected override setState(state: State) {
@ -298,8 +297,8 @@ export class GraphApp extends App {
}; };
} }
private refresh(state: State, oldState: State) {
this.callback?.(state, oldState);
private refresh(state: State, previousRowCount: number | undefined) {
this.callback?.(state, previousRowCount);
} }
} }

Loading…
Cancel
Save