Browse Source

Ensures hidden refs are shown for the correct repo

main
Eric Amodio 2 years ago
parent
commit
3208ac487f
1 changed files with 21 additions and 11 deletions
  1. +21
    -11
      src/plus/webviews/graph/graphWebview.ts

+ 21
- 11
src/plus/webviews/graph/graphWebview.ts View File

@ -945,9 +945,8 @@ export class GraphWebview extends WebviewBase {
return false;
}
const hiddenRefs = this.getHiddenRefs();
return this.notify(DidChangeRefsVisibilityNotificationType, {
hiddenRefs: await this.getHiddenRefsById(hiddenRefs),
hiddenRefs: this.getHiddenRefs(),
});
}
@ -1121,13 +1120,21 @@ export class GraphWebview extends WebviewBase {
}
private getHiddenRefs(): Record<string, GraphHiddenRef> | undefined {
return this.container.storage.getWorkspace('graph:hiddenRefs');
return this.filterHiddenRefs(this.container.storage.getWorkspace('graph:hiddenRefs'));
}
private async getHiddenRefsById(
hiddenRefs: Record<string, GraphHiddenRef> | undefined,
): Promise<GraphHiddenRefs | undefined> {
if (hiddenRefs == null) return undefined;
private filterHiddenRefs(hiddenRefs: Record<string, GraphHiddenRef> | undefined): GraphHiddenRefs | undefined {
if (hiddenRefs == null || this.repository == null) return undefined;
const filteredRefs: GraphHiddenRefs = {};
for (const id in hiddenRefs) {
if (getRepoPathFromBranchOrTagId(id) === this.repository.path) {
filteredRefs[id] = hiddenRefs[id];
}
}
return filteredRefs;
// This validation has too much performance impact. So we decided to comment those lines
// for v13 and have it as tech debt to solve after we launch.
@ -1159,8 +1166,9 @@ export class GraphWebview extends WebviewBase {
// return filteredHiddenRefsById;
// For v13, we return directly the hidden refs without validating them
return Promise.resolve(hiddenRefs);
return hiddenRefs;
}
private getColumnSettings(columns: Record<GraphColumnName, GraphColumnConfig> | undefined): GraphColumnsSettings {
const columnsSettings: GraphColumnsSettings = {
...defaultGraphColumnsSettings,
@ -1297,8 +1305,6 @@ export class GraphWebview extends WebviewBase {
}
const columns = this.getColumns();
const hiddenRefs = this.getHiddenRefs();
const hiddenRefsByIds = await this.getHiddenRefsById(hiddenRefs);
return {
previewBanner: this.previewBanner,
@ -1325,7 +1331,7 @@ export class GraphWebview extends WebviewBase {
context: {
header: this.getColumnHeaderContext(columns),
},
hiddenRefs: hiddenRefsByIds,
hiddenRefs: this.getHiddenRefs(),
nonce: this.cspNonce,
workingTreeStats: getSettledValue(workingStatsResult) ?? { added: 0, deleted: 0, modified: 0 },
};
@ -1981,3 +1987,7 @@ function isGraphItemRefContext(item: unknown, refType?: GitReference['refType'])
(refType == null || item.webviewItemValue.ref.refType === refType)
);
}
function getRepoPathFromBranchOrTagId(id: string): string {
return id.split('|', 1)[0];
}

Loading…
Cancel
Save