feat: add auto update support (#65)

This commit is contained in:
2026-05-16 00:09:14 -07:00
committed by GitHub
parent 105713361e
commit 91a01b86a9
71 changed files with 2368 additions and 188 deletions
+27
View File
@@ -15,6 +15,12 @@ export type ShowMessageBox = (options: {
cancelId?: number;
}) => Promise<MessageBoxResultLike>;
export interface UpdateDialogPresenterDeps {
showMessageBox: ShowMessageBox;
focusApp?: () => void;
platform?: NodeJS.Platform;
}
export async function showNoUpdateDialog(
showMessageBox: ShowMessageBox,
version: string,
@@ -27,6 +33,27 @@ export async function showNoUpdateDialog(
});
}
function maybeFocusAppForDialog(deps: UpdateDialogPresenterDeps): void {
if ((deps.platform ?? process.platform) !== 'darwin') return;
deps.focusApp?.();
}
export function createUpdateDialogPresenter(deps: UpdateDialogPresenterDeps) {
const showFocusedMessageBox: ShowMessageBox = async (options) => {
maybeFocusAppForDialog(deps);
return deps.showMessageBox(options);
};
return {
showNoUpdateDialog: (version: string) => showNoUpdateDialog(showFocusedMessageBox, version),
showUpdateAvailableDialog: (version: string) =>
showUpdateAvailableDialog(showFocusedMessageBox, version),
showUpdateFailedDialog: (message: string) =>
showUpdateFailedDialog(showFocusedMessageBox, message),
showRestartDialog: () => showRestartDialog(showFocusedMessageBox),
};
}
export async function showUpdateAvailableDialog(
showMessageBox: ShowMessageBox,
version: string,