Skip to content

Commit

Permalink
chore: add debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
maparr committed Dec 1, 2023
1 parent 716ff58 commit 72ba302
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions desktop/main/autoUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const checkUpdates = async (
};

export const installUpdate = () => {
logger.log('installUpdate', 'quitAndInstall');
autoUpdater.quitAndInstall(true, true);
};

Expand Down
3 changes: 2 additions & 1 deletion desktop/main/createMainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default () => {

// Push to $quit event stream
const handleQuit = async (event) => {
logger.log('handleQuit', $isAppClosing.value);
if (!$isAppClosing.value) {
$quit.next(event);
}
Expand All @@ -51,8 +52,8 @@ export default () => {
app.on('before-quit', handleQuit);
// @ts-ignore
autoUpdater.on('before-quit-for-update', () => {
$isUpdateInProgress.next(true);
logger.log('before-quit', 'before-quit-for-update');
$isUpdateInProgress.next(true);
// ask about the choose and close the app with app.quit()
});

Expand Down
23 changes: 18 additions & 5 deletions desktop/main/promptBeforeClose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,34 @@ const promptBeforeClose = (
return;
}

logger.log('handleClosingApp', 'isUpdateInProgress', isUpdateInProgress);

if (isUpdateInProgress) {
const updatePromptResult = await showUpdatePrompt(mainWindow);
logger.log('handleClosingApp', 'updatePromptResult', updatePromptResult);
if (updatePromptResult === UpdatePromptResult.RESTART_NOW) {
isCloseTriggered = true;
mainWindow.webContents.send(ipcConsts.CLOSING_APP);
await quit();
return;
}
}

const promptResult =
((await Boolean(managers?.node?.isNodeRunning())) &&
(await showPrompt(mainWindow))) ||
CloseAppPromptResult.CLOSE;
if (
[
UpdatePromptResult.POSTPONE_UPDATE,
UpdatePromptResult.CANCELED,
].includes(updatePromptResult)
) {
setTimeout(notify, 1000, mainWindow);
mainWindow.hide();
$showWindowOnLoad.next(false);
mainWindow.reload();
return;
}
}

const promptResult = await showPrompt(mainWindow);
logger.log('handleClosingApp', 'promptResult', promptResult);
if (promptResult === CloseAppPromptResult.KEEP_SMESHING) {
setTimeout(notify, 1000, mainWindow);
mainWindow.hide();
Expand Down
16 changes: 13 additions & 3 deletions desktop/main/sources/autoUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ const handleAutoUpdates = (
StoreService.set('startNodeOnNextLaunch', true);
await managers.node.stopNode();
}
/*
here we have an issue
installUpdate()
from IPC
from here ( but it is forced update )
* */
logger.log('forceUpdate', 'installUpdate');
installUpdate();
} catch (err) {
logger.error('forceUpdate', err);
Expand Down Expand Up @@ -136,9 +145,10 @@ const handleAutoUpdates = (
$request.next(true);
}),
// Trigger installation
fromIPC<void>(ipcConsts.AU_REQUEST_INSTALL).subscribe(() =>
installUpdate()
),
fromIPC<void>(ipcConsts.AU_REQUEST_INSTALL).subscribe(() => {
logger.log('ipcConsts.AU_REQUEST_INSTALL', 'installUpdate');
return installUpdate();
}),
];

return () => subs.forEach((sub) => sub.unsubscribe());
Expand Down

0 comments on commit 72ba302

Please sign in to comment.