Преглед на файлове

Adds refresh command for the Graph

main
Eric Amodio преди 2 години
родител
ревизия
680e23ccad
променени са 5 файла, в които са добавени 42 реда и са изтрити 12 реда
  1. +15
    -0
      package.json
  2. +3
    -1
      src/constants.ts
  3. +15
    -2
      src/plus/webviews/graph/graphWebview.ts
  4. +1
    -1
      src/plus/webviews/timeline/timelineWebview.ts
  5. +8
    -8
      src/webviews/webviewBase.ts

+ 15
- 0
package.json Целия файл

@ -3966,6 +3966,12 @@
"icon": "$(gitlens-graph)"
},
{
"command": "gitlens.refreshGraphPage",
"title": "Refresh",
"category": "GitLens",
"icon": "$(refresh)"
},
{
"command": "gitlens.showSettingsPage",
"title": "Open Settings",
"category": "GitLens",
@ -6425,6 +6431,10 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.refreshGraphPage",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#views",
"when": "false"
},
@ -8159,6 +8169,11 @@
"command": "gitlens.refreshTimelinePage",
"when": "gitlens:timelinePage:focused",
"group": "navigation@-99"
},
{
"command": "gitlens.refreshGraphPage",
"when": "gitlens:graphPage:focused",
"group": "navigation@-99"
}
],
"editor/title/context": [

+ 3
- 1
src/constants.ts Целия файл

@ -152,7 +152,9 @@ export const enum Commands {
PlusStartPreviewTrial = 'gitlens.plus.startPreviewTrial',
PlusValidate = 'gitlens.plus.validate',
QuickOpenFileHistory = 'gitlens.quickOpenFileHistory',
RefreshGraphPage = 'gitlens.refreshGraphPage',
RefreshHover = 'gitlens.refreshHover',
RefreshTimelinePage = 'gitlens.refreshTimelinePage',
ResetAvatarCache = 'gitlens.resetAvatarCache',
ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings',
ResetTrackedUsage = 'gitlens.resetTrackedUsage',
@ -199,7 +201,6 @@ export const enum Commands {
ShowStashesView = 'gitlens.showStashesView',
ShowTagsView = 'gitlens.showTagsView',
ShowWorktreesView = 'gitlens.showWorktreesView',
RefreshTimelinePage = 'gitlens.refreshTimelinePage',
ShowCommitDetailsView = 'gitlens.showCommitDetailsView',
ShowTimelinePage = 'gitlens.showTimelinePage',
ShowTimelineView = 'gitlens.showTimelineView',
@ -246,6 +247,7 @@ export const enum ContextKeys {
DisabledToggleCodeLens = 'gitlens:disabledToggleCodeLens',
Disabled = 'gitlens:disabled',
Enabled = 'gitlens:enabled',
GraphPageFocused = 'gitlens:graphPage:focused',
HasConnectedRemotes = 'gitlens:hasConnectedRemotes',
HasRemotes = 'gitlens:hasRemotes',
HasRichRemotes = 'gitlens:hasRichRemotes',

+ 15
- 2
src/plus/webviews/graph/graphWebview.ts Целия файл

@ -132,6 +132,10 @@ export class GraphWebview extends WebviewBase {
return this.getState();
}
protected override registerCommands(): Disposable[] {
return [registerCommand(Commands.RefreshGraphPage, () => this.refresh(true))];
}
protected override onInitializing(): Disposable[] | undefined {
this._theme = window.activeColorTheme;
return [window.onDidChangeActiveColorTheme(this.onThemeChanged, this)];
@ -158,9 +162,18 @@ export class GraphWebview extends WebviewBase {
}
protected override onFocusChanged(focused: boolean): void {
if (focused && this.selection != null) {
void GitActions.Commit.showDetailsView(this.selection[0], { pin: true, preserveFocus: true });
if (focused) {
// If we are becoming focused, delay it a bit to give the UI time to update
setTimeout(() => void setContext(ContextKeys.GraphPageFocused, focused), 0);
if (this.selection != null) {
void GitActions.Commit.showDetailsView(this.selection[0], { pin: true, preserveFocus: true });
}
return;
}
void setContext(ContextKeys.GraphPageFocused, focused);
}
protected override onVisibilityChanged(visible: boolean): void {

+ 1
- 1
src/plus/webviews/timeline/timelineWebview.ts Целия файл

@ -106,7 +106,7 @@ export class TimelineWebview extends WebviewBase {
}
protected override registerCommands(): Disposable[] {
return [registerCommand(Commands.RefreshTimelinePage, () => this.refresh())];
return [registerCommand(Commands.RefreshTimelinePage, () => this.refresh(true))];
}
protected override onFocusChanged(focused: boolean): void {

+ 8
- 8
src/webviews/webviewBase.ts Целия файл

@ -103,12 +103,7 @@ export abstract class WebviewBase implements Disposable {
this._panel.webview.html = await this.getHtml(this._panel.webview);
} else {
const html = await this.getHtml(this._panel.webview);
// Reset the html to get the webview to reload
this._panel.webview.html = '';
this._panel.webview.html = html;
await this.refresh(true);
this._panel.reveal(this._panel.viewColumn ?? ViewColumn.Active, false);
}
}
@ -131,10 +126,15 @@ export abstract class WebviewBase implements Disposable {
protected includeBody?(): string | Promise<string>;
protected includeEndOfBody?(): string | Promise<string>;
protected async refresh(): Promise<void> {
protected async refresh(force?: boolean): Promise<void> {
if (this._panel == null) return;
this._panel.webview.html = await this.getHtml(this._panel.webview);
const html = await this.getHtml(this._panel.webview);
if (force) {
// Reset the html to get the webview to reload
this._panel.webview.html = '';
}
this._panel.webview.html = html;
}
private onPanelDisposed() {

Зареждане…
Отказ
Запис