Skip to content

Commit

Permalink
Fixes #2315, #2329 commit details preferences
Browse files Browse the repository at this point in the history
- uses global storage instead of workspace storage
- fixes _pendingContext.preferences
- updates autolinksExpanded optimistically in UI
  • Loading branch information
d13 committed Nov 9, 2022
1 parent f58c3ab commit 40b6bc6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -37,6 +37,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#2292](https://github.com/gitkraken/vscode-gitlens/issues/2292) - Push button in BranchTrackingStatusNode of non-current branch does not trigger "Push force"
- Fixes [#1488](https://github.com/gitkraken/vscode-gitlens/issues/1488) - Open Folder History not working with non-English language pack
- Fixes [#2303](https://github.com/gitkraken/vscode-gitlens/issues/2303) - "Googlesource" gerrit only supports two levels of domain — thanks to [PR #2304](https://github.com/gitkraken/vscode-gitlens/pull/2304) by Matt Buckley ([@Mattadore](https://github.com/Mattadore))
- Fixes [#2315](https://github.com/gitkraken/vscode-gitlens/issues/2315) - Commit details secondary side bar banner doesn't stay dismissed
- Fixes [#2329](https://github.com/gitkraken/vscode-gitlens/issues/2329) - Remember UI settings in Commit Details panel

## [13.0.4] - 2002-11-03

Expand Down
8 changes: 4 additions & 4 deletions src/storage.ts
Expand Up @@ -163,6 +163,10 @@ export interface GlobalStorage {
welcome: {
visible?: boolean;
};
commitDetails: {
autolinksExpanded?: boolean;
dismissed?: string[];
};
};
}

Expand Down Expand Up @@ -198,10 +202,6 @@ export interface WorkspaceStorage {
keepResults?: boolean;
pinned?: StoredPinnedItems;
};
commitDetails: {
autolinksExpanded?: boolean;
dismissed?: string[];
};
};

pinned: {
Expand Down
5 changes: 5 additions & 0 deletions src/webviews/apps/commitDetails/commitDetails.ts
Expand Up @@ -163,6 +163,11 @@ export class CommitDetailsApp extends App<Serialized<State>> {
}

private onExpandedChange(e: WebviewPaneExpandedChangeEventDetail) {
this.state.preferences = {
...this.state.preferences,
autolinksExpanded: e.expanded,
};

this.sendCommand(PreferencesCommandType, { autolinksExpanded: e.expanded });
}

Expand Down
27 changes: 15 additions & 12 deletions src/webviews/commitDetails/commitDetailsWebviewView.ts
Expand Up @@ -150,9 +150,9 @@ export class CommitDetailsWebviewView extends WebviewViewBase<State, Serialized<
if (this._context.preferences == null) {
this.updatePendingContext({
preferences: {
autolinksExpanded: this.container.storage.getWorkspace('views:commitDetails:autolinksExpanded'),
autolinksExpanded: this.container.storage.get('views:commitDetails:autolinksExpanded'),
avatars: configuration.get('views.commitDetails.avatars'),
dismissed: this.container.storage.getWorkspace('views:commitDetails:dismissed'),
dismissed: this.container.storage.get('views:commitDetails:dismissed'),
files: configuration.get('views.commitDetails.files'),
},
});
Expand Down Expand Up @@ -525,30 +525,33 @@ export class CommitDetailsWebviewView extends WebviewViewBase<State, Serialized<
return;
}

const changes: Preferences = {};
const changes: Preferences = {
...this._context.preferences,
...this._pendingContext?.preferences,
};

if (this._context.preferences?.autolinksExpanded !== preferences.autolinksExpanded) {
void this.container.storage.storeWorkspace(
'views:commitDetails:autolinksExpanded',
preferences.autolinksExpanded,
);
if (
preferences.autolinksExpanded != null &&
this._context.preferences?.autolinksExpanded !== preferences.autolinksExpanded
) {
void this.container.storage.store('views:commitDetails:autolinksExpanded', preferences.autolinksExpanded);

changes.autolinksExpanded = preferences.autolinksExpanded;
}

if (this._context.preferences?.avatars !== preferences.avatars) {
if (preferences.avatars != null && this._context.preferences?.avatars !== preferences.avatars) {
void configuration.updateEffective('views.commitDetails.avatars', preferences.avatars);

changes.avatars = preferences.avatars;
}

if (this._context.preferences?.dismissed !== preferences.dismissed) {
void this.container.storage.storeWorkspace('views:commitDetails:dismissed', preferences.dismissed);
if (preferences.dismissed != null && this._context.preferences?.dismissed !== preferences.dismissed) {
void this.container.storage.store('views:commitDetails:dismissed', preferences.dismissed);

changes.dismissed = preferences.dismissed;
}

if (this._context.preferences?.files !== preferences.files) {
if (preferences.files != null && this._context.preferences?.files !== preferences.files) {
if (this._context.preferences?.files?.compact !== preferences.files?.compact) {
void configuration.updateEffective('views.commitDetails.files.compact', preferences.files?.compact);
}
Expand Down

0 comments on commit 40b6bc6

Please sign in to comment.