Skip to content

Commit d60f1bc

Browse files
committed
fix(login): do not dismiss "latest changes" dialog automatically during login
fixes #2365
1 parent c989796 commit d60f1bc

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

src/app/core/ui/latest-changes/latest-changes-dialog.service.spec.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
* along with ndb-core. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
import { TestBed } from "@angular/core/testing";
18+
import { fakeAsync, TestBed, tick } from "@angular/core/testing";
1919

2020
import { LatestChangesService } from "./latest-changes.service";
21-
import { MatDialog } from "@angular/material/dialog";
21+
import { MatDialog, MatDialogRef } from "@angular/material/dialog";
2222
import { LatestChangesDialogService } from "./latest-changes-dialog.service";
2323
import { environment } from "../../../../environments/environment";
24+
import { NEVER, of } from "rxjs";
2425

2526
describe("LatestChangesDialogService", () => {
2627
let service: LatestChangesDialogService;
@@ -34,6 +35,9 @@ describe("LatestChangesDialogService", () => {
3435
]);
3536

3637
mockDialog = jasmine.createSpyObj("mockDialog", ["open"]);
38+
mockDialog.open.and.returnValue({
39+
afterClosed: () => of(NEVER),
40+
} as MatDialogRef<void>);
3741

3842
TestBed.configureTestingModule({
3943
providers: [
@@ -79,4 +83,20 @@ describe("LatestChangesDialogService", () => {
7983

8084
expect(mockDialog.open).not.toHaveBeenCalled();
8185
});
86+
87+
it("should update stored version after user closes dialog", fakeAsync(() => {
88+
spyOn(Storage.prototype, "setItem");
89+
90+
mockDialog.open.and.returnValue({
91+
afterClosed: () => of(true),
92+
} as MatDialogRef<boolean>);
93+
94+
service.showLatestChanges();
95+
tick();
96+
97+
expect(Storage.prototype.setItem).toHaveBeenCalledWith(
98+
LatestChangesDialogService.VERSION_KEY,
99+
environment.appVersion,
100+
);
101+
}));
82102
});

src/app/core/ui/latest-changes/latest-changes-dialog.service.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,23 @@ export class LatestChangesDialogService {
4646
* @param previousVersion (Optional) previous version back to which all changes should be displayed
4747
*/
4848
public showLatestChanges(previousVersion?: string): void {
49-
this.dialog.open(ChangelogComponent, {
50-
width: "80%",
51-
data: this.latestChangesService.getChangelogsBetweenVersions(
52-
this.getCurrentVersion(),
53-
previousVersion,
54-
),
55-
});
49+
this.dialog
50+
.open(ChangelogComponent, {
51+
width: "80%",
52+
data: this.latestChangesService.getChangelogsBetweenVersions(
53+
this.getCurrentVersion(),
54+
previousVersion,
55+
),
56+
})
57+
.afterClosed()
58+
.subscribe(() => this.updateCurrentVersion());
59+
}
60+
61+
private updateCurrentVersion() {
62+
window.localStorage.setItem(
63+
LatestChangesDialogService.VERSION_KEY,
64+
this.getCurrentVersion(),
65+
);
5666
}
5767

5868
/**
@@ -65,9 +75,5 @@ export class LatestChangesDialogService {
6575
if (previousVersion && this.getCurrentVersion() !== previousVersion) {
6676
this.showLatestChanges(previousVersion);
6777
}
68-
window.localStorage.setItem(
69-
LatestChangesDialogService.VERSION_KEY,
70-
this.getCurrentVersion(),
71-
);
7278
}
7379
}

0 commit comments

Comments
 (0)