Skip to content

Commit 6d1aa2f

Browse files
committed
feat(updater): update version and enhance update checking logic
Updated the version to 0.1.4 and refactored the update checking mechanism to ensure updates are checked every time the window is shown or finishes loading.
1 parent 8a09ae8 commit 6d1aa2f

File tree

4 files changed

+6
-20
lines changed

4 files changed

+6
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "electron-modular-boilerplate",
33
"private": true,
4-
"version": "0.1.3",
4+
"version": "0.1.4",
55
"type": "module",
66
"main": "dist-main/app.js",
77
"author": "traeop",

src/main/app/window.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { isDev } from "#shared/utils.js";
99

1010
import { menu } from "#main/config.js";
1111

12-
import { getElectronStorage } from "#main/@shared/store.js";
13-
1412
import type { TWindowManager } from "../types.js";
1513
import { MENU_PROVIDER, TRAY_PROVIDER, UPDATER_PROVIDER } from "./tokens.js";
1614
import type {
@@ -86,12 +84,7 @@ export class AppWindow implements TWindowManager {
8684

8785
onShow(): void {
8886
this.isWillClose = false;
89-
const userId = getElectronStorage("userId");
90-
const authToken = getElectronStorage("authToken");
91-
92-
if (userId && authToken) {
93-
this.updaterProvider.checkForUpdates();
94-
}
87+
this.updaterProvider.checkForUpdates();
9588
}
9689

9790
onClose(event: Event, window: BrowserWindow): void {

src/main/updater/window.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ vi.mock("@devisfuture/electron-modular", () => ({
55
}));
66

77
describe("UpdaterWindow", () => {
8-
it("checks for updates on first load only once", async () => {
8+
it("calls checkForUpdates each time the load finishes", async () => {
99
const { UpdaterWindow } = await import("./window.js");
1010

1111
const checkForUpdatesService = {
@@ -17,7 +17,7 @@ describe("UpdaterWindow", () => {
1717
window.onWebContentsDidFinishLoad();
1818
window.onWebContentsDidFinishLoad();
1919

20-
expect(checkForUpdatesService.checkForUpdates).toHaveBeenCalledTimes(1);
20+
expect(checkForUpdatesService.checkForUpdates).toHaveBeenCalledTimes(2);
2121
});
2222

2323
it("checks for updates when window is shown after first", async () => {

src/main/updater/window.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@ import { CheckForUpdatesService } from "./services/check-for-updates.js";
1616
},
1717
})
1818
export class UpdaterWindow implements TWindowManager {
19-
private isCheckFirst = true;
2019
constructor(private checkForUpdatesService: CheckForUpdatesService) {}
2120

2221
onWebContentsDidFinishLoad(): void {
23-
if (this.isCheckFirst) {
24-
this.checkForUpdatesService.checkForUpdates();
25-
this.isCheckFirst = false;
26-
}
22+
this.checkForUpdatesService.checkForUpdates();
2723
}
2824

2925
onShow() {
30-
console.log("UpdaterWindow onShowed");
31-
if (!this.isCheckFirst) {
32-
this.checkForUpdatesService.checkForUpdates();
33-
}
26+
this.checkForUpdatesService.checkForUpdates();
3427
}
3528
}

0 commit comments

Comments
 (0)