Skip to content

Commit

Permalink
[DDW-691] Add electron dialog to check second instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tomislavhoracek committed Oct 26, 2021
1 parent e2e27be commit f3d307a
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion source/main/index.js
Expand Up @@ -398,8 +398,38 @@ app.on('open-url', (event, url) => {

if (!isSingleInstance) {
logger.info('[Custom-Protocol] isSingleInstance - Quit: ', { isSingleInstance });
app.quit();
if (mainWindow) {
const exitSelfnodeDialogOptions = {
buttons: ['Yes', 'No'],
type: 'warning',
title: 'Safe EXIT',
message: 'Safe EXIT - not a single instance',
defaultId: 0,
cancelId: 1,
noLink: true,
};
dialog.showMessageBox(
mainWindow,
exitSelfnodeDialogOptions
);
}
safeExit();
} else {
if (mainWindow) {
const exitSelfnodeDialogOptions2 = {
buttons: ['Yes', 'No'],
type: 'warning',
title: 'It is single instance',
message: '...',
defaultId: 0,
cancelId: 1,
noLink: true,
};
dialog.showMessageBox(
mainWindow,
exitSelfnodeDialogOptions2
);
}
logger.info('[Custom-Protocol] isSingleInstance - Continue: ', { isSingleInstance });
/* app.on('will-finish-launching' , () => {
logger.info('[Custom-Protocol] will-finish-launching');
Expand All @@ -422,6 +452,21 @@ if (!isSingleInstance) {
});
}); */
app.on('second-instance', () => {
if (mainWindow) {
const exitSelfnodeDialogOptions3 = {
buttons: ['Yes', 'No'],
type: 'warning',
title: 'On second instance',
message: '...',
defaultId: 0,
cancelId: 1,
noLink: true,
};
dialog.showMessageBox(
mainWindow,
exitSelfnodeDialogOptions3
);
}
logger.info('[Custom-Protocol] isSingleInstance - Is second instance');
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
Expand Down

0 comments on commit f3d307a

Please sign in to comment.