Skip to content

Commit 811ac42

Browse files
committed
feat(menu): no updates available auto-hide
Signed-off-by: Adam Setch <[email protected]>
1 parent 15f40e9 commit 811ac42

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/main/updater.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class AppUpdater {
2222
private readonly menubar: Menubar;
2323
private readonly menuBuilder: MenuBuilder;
2424
private started = false;
25+
private noUpdateMessageTimeout?: NodeJS.Timeout;
2526

2627
constructor(menubar: Menubar, menuBuilder: MenuBuilder) {
2728
this.menubar = menubar;
@@ -56,6 +57,9 @@ export default class AppUpdater {
5657
logInfo('auto updater', 'Checking for update');
5758
this.menuBuilder.setCheckForUpdatesMenuEnabled(false);
5859
this.menuBuilder.setNoUpdateAvailableMenuVisibility(false);
60+
61+
// Clear any existing timeout when starting a new check
62+
this.clearNoUpdateTimeout();
5963
});
6064

6165
autoUpdater.on('update-available', () => {
@@ -84,6 +88,12 @@ export default class AppUpdater {
8488
this.menuBuilder.setNoUpdateAvailableMenuVisibility(true);
8589
this.menuBuilder.setUpdateAvailableMenuVisibility(false);
8690
this.menuBuilder.setUpdateReadyForInstallMenuVisibility(false);
91+
92+
// Auto-hide the "no updates available" message
93+
this.clearNoUpdateTimeout();
94+
this.noUpdateMessageTimeout = setTimeout(() => {
95+
this.menuBuilder.setNoUpdateAvailableMenuVisibility(false);
96+
}, APPLICATION.UPDATE_NOT_AVAILABLE_DISPLAY_MS);
8797
});
8898

8999
autoUpdater.on('update-cancelled', () => {
@@ -121,12 +131,22 @@ export default class AppUpdater {
121131
this.menubar.tray.setToolTip(`${APPLICATION.NAME}\n${status}`);
122132
}
123133

134+
private clearNoUpdateTimeout() {
135+
if (this.noUpdateMessageTimeout) {
136+
clearTimeout(this.noUpdateMessageTimeout);
137+
this.noUpdateMessageTimeout = undefined;
138+
}
139+
}
140+
124141
private resetState() {
125142
this.menubar.tray.setToolTip(APPLICATION.NAME);
126143
this.menuBuilder.setCheckForUpdatesMenuEnabled(true);
127144
this.menuBuilder.setNoUpdateAvailableMenuVisibility(false);
128145
this.menuBuilder.setUpdateAvailableMenuVisibility(false);
129146
this.menuBuilder.setUpdateReadyForInstallMenuVisibility(false);
147+
148+
// Clear any pending timeout
149+
this.clearNoUpdateTimeout();
130150
}
131151

132152
private showUpdateReadyDialog(releaseName: string) {

src/shared/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ export const APPLICATION = {
1616
NOTIFICATION_SOUND: 'clearly.mp3',
1717

1818
UPDATE_CHECK_INTERVAL_MS: 24 * 60 * 60 * 1000, // 24 hours
19+
20+
UPDATE_NOT_AVAILABLE_DISPLAY_MS: 60 * 1000, // 60 seconds
1921
};

0 commit comments

Comments
 (0)