Skip to content

Commit

Permalink
fix(auto-update-manager): listen to events instead of invokes; broadc…
Browse files Browse the repository at this point in the history
…ast to all windows, not only the focused one (#5506)
  • Loading branch information
gribnoysup authored Feb 27, 2024
1 parent 7d3b82a commit 708287e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/compass/src/main/auto-update-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ describe('CompassAutoUpdateManager', function () {

it('should restart the app if user confirms', async function () {
const restartToastIpcPrompt = sandbox
.stub(ipcMain!, 'broadcastFocused')
.stub(ipcMain!, 'broadcast')
.callsFake((arg) => {
expect(arg).to.equal('autoupdate:update-download-success');
setTimeout(() => {
Expand All @@ -329,7 +329,7 @@ describe('CompassAutoUpdateManager', function () {

it('should transition to restart dismissed if user does not confirm restart', async function () {
const restartToastIpcPrompt = sandbox
.stub(ipcMain!, 'broadcastFocused')
.stub(ipcMain!, 'broadcast')
.callsFake((arg) => {
expect(arg).to.equal('autoupdate:update-download-success');
setTimeout(() => {
Expand Down
10 changes: 5 additions & 5 deletions packages/compass/src/main/auto-update-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ const STATE_UPDATE: Record<
this.maybeInterrupt();

if (isDownloadForManualCheck) {
ipcMain?.broadcastFocused('autoupdate:update-download-in-progress');
ipcMain?.broadcast('autoupdate:update-download-in-progress');
}
autoUpdater.checkForUpdates();
},
Expand All @@ -379,7 +379,7 @@ const STATE_UPDATE: Record<

this.maybeInterrupt();

ipcMain?.broadcastFocused('autoupdate:update-download-success');
ipcMain?.broadcast('autoupdate:update-download-success');
},
},
[AutoUpdateManagerState.ManualDownload]: {
Expand Down Expand Up @@ -431,7 +431,7 @@ const STATE_UPDATE: Record<
[AutoUpdateManagerState.DownloadingError]: {
nextStates: [AutoUpdateManagerState.UserPromptedManualCheck],
enter: (_updateManager, _fromState, error) => {
ipcMain?.broadcastFocused('autoupdate:update-download-failed');
ipcMain?.broadcast('autoupdate:update-download-failed');
log.error(
mongoLogId(1001000129),
'AutoUpdateManager',
Expand Down Expand Up @@ -663,12 +663,12 @@ class CompassAutoUpdateManager {
this.setState(AutoUpdateManagerState.UserPromptedManualCheck);
});

ipcMain?.handle(
ipcMain?.on(
'autoupdate:update-download-restart-confirmed',
this.handleIpcUpdateDownloadRestartConfirmed.bind(this)
);

ipcMain?.handle(
ipcMain?.on(
'autoupdate:update-download-restart-dismissed',
this.handleIpcUpdateDownloadRestartDismissed.bind(this)
);
Expand Down

0 comments on commit 708287e

Please sign in to comment.