Fix current patchset not updated after Edit Publish
Gr-patch-range-select was updated thanks to subscribe,
so we subscribe gr-file-list-header to patchnum as well.
Issue: Bug 16156
Release-Notes: skip
Change-Id: I327d9c2e5911a26a9627bcf27df5930a482f9794
(cherry picked from commit 69060bf906dda6bdcaf7f42b08518a5dd11649d9)
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index 61ad937..3c0687a 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -1241,7 +1241,6 @@
<gr-download-dialog
id="downloadDialog"
.change=${this.change}
- .patchNum=${this.patchRange?.patchNum}
.config=${this.serverConfig?.download}
@close=${this.handleDownloadDialogClose}
></gr-download-dialog>
@@ -1602,8 +1601,6 @@
.editMode=${this.getEditMode()}
.loggedIn=${this.loggedIn}
.shownFileCount=${this.shownFileCount}
- .patchNum=${this.patchRange?.patchNum}
- .basePatchNum=${this.patchRange?.basePatchNum}
.filesExpanded=${this.fileList?.filesExpanded}
@open-diff-prefs=${this.handleOpenDiffPrefs}
@open-download-dialog=${this.handleOpenDownloadDialog}
diff --git a/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.ts b/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.ts
index 6603149..2e84143 100644
--- a/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.ts
@@ -23,6 +23,9 @@
import {PaperTabsElement} from '@polymer/paper-tabs/paper-tabs';
import {BindValueChangeEvent} from '../../../types/events';
import {ShortcutController} from '../../lit/shortcut-controller';
+import {subscribe} from '../../lit/subscription-controller';
+import {resolve} from '../../../models/dependency';
+import {changeModelToken} from '../../../models/change/change-model';
@customElement('gr-download-dialog')
export class GrDownloadDialog extends LitElement {
@@ -44,15 +47,21 @@
@property({type: Object})
config?: DownloadInfo;
- @property({type: String})
- patchNum: PatchSetNum | undefined;
+ @state() patchNum?: PatchSetNum;
@state() private selectedScheme?: string;
private readonly shortcuts = new ShortcutController(this);
+ private readonly getChangeModel = resolve(this, changeModelToken);
+
constructor() {
super();
+ subscribe(
+ this,
+ () => this.getChangeModel().patchNum$,
+ x => (this.patchNum = x)
+ );
for (const key of ['1', '2', '3', '4', '5']) {
this.shortcuts.addLocal({key}, e => this.handleNumberKey(e));
}
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
index 832738b..2c3e04b 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
@@ -42,6 +42,7 @@
import {subscribe} from '../../lit/subscription-controller';
import {configModelToken} from '../../../models/config/config-model';
import {createChangeUrl} from '../../../models/views/change';
+import {changeModelToken} from '../../../models/change/change-model';
@customElement('gr-file-list-header')
export class GrFileListHeader extends LitElement {
@@ -89,17 +90,15 @@
shownFileCount = 0;
@property({type: String})
- patchNum?: PatchSetNum;
-
- @property({type: String})
- basePatchNum?: BasePatchSetNum;
-
- @property({type: String})
filesExpanded?: FilesExpandedState;
@property({type: Object})
revisionInfo?: RevisionInfo;
+ @state() patchNum?: PatchSetNum;
+
+ @state() basePatchNum?: BasePatchSetNum;
+
@state()
diffPrefs?: DiffPreferencesInfo;
@@ -127,6 +126,8 @@
private readonly getNavigation = resolve(this, navigationToken);
+ private readonly getChangeModel = resolve(this, changeModelToken);
+
constructor() {
super();
subscribe(
@@ -144,6 +145,16 @@
this.serverConfig = config;
}
);
+ subscribe(
+ this,
+ () => this.getChangeModel().patchNum$,
+ x => (this.patchNum = x)
+ );
+ subscribe(
+ this,
+ () => this.getChangeModel().basePatchNum$,
+ x => (this.basePatchNum = x)
+ );
}
static override styles = [