Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ nsis:
oneClick: false
perMachine: true
allowElevation: true
runAfterFinish: true
differentialPackage: false
artifactName: Switchify-PC-Setup-${version}-${arch}.${ext}
4 changes: 2 additions & 2 deletions src/main/updates/update-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('UpdateService', () => {
expect(updater.quitAndInstall).not.toHaveBeenCalled();
});

it('calls quitAndInstall after an update is downloaded', async () => {
it('installs downloaded updates silently and relaunches the app', async () => {
const updater = new FakeUpdater();
updater.checkForUpdates.mockImplementation(async () => {
updater.emit('update-available', updateInfo({ version: '0.1.1' }));
Expand All @@ -153,7 +153,7 @@ describe('UpdateService', () => {
await service.downloadUpdate();

expect(service.installDownloadedUpdate()).toEqual({ ok: true });
expect(updater.quitAndInstall).toHaveBeenCalledWith(false, true);
expect(updater.quitAndInstall).toHaveBeenCalledWith(true, true);
});

it('maps updater errors during checks to check_failed', async () => {
Expand Down
5 changes: 4 additions & 1 deletion src/main/updates/update-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export type UpdateServiceOptions = {

type UpdateOperation = 'idle' | 'checking' | 'downloading';

const INSTALL_UPDATE_SILENTLY = true;
const FORCE_RUN_AFTER_INSTALL = true;

export class UpdateService {
private readonly isPackaged: boolean;
private readonly platform: NodeJS.Platform;
Expand Down Expand Up @@ -182,7 +185,7 @@ export class UpdateService {
return { ok: false, reason: 'not_downloaded' };
}

this.autoUpdater.quitAndInstall(false, true);
this.autoUpdater.quitAndInstall(INSTALL_UPDATE_SILENTLY, FORCE_RUN_AFTER_INSTALL);
return { ok: true };
}

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/UpdatesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function UpdatesPanel({
) : null}
{showInstallButton ? (
<button type="button" className="primary-button" onClick={() => void onInstallDownloaded()}>
Install update
Install and restart
</button>
) : null}
</div>
Expand Down