Skip to content

Commit

Permalink
Fixing update and run at start ? (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
narafrost authored Jan 2, 2024
2 parents 05014d6 + c688cc8 commit cb393e9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
16 changes: 14 additions & 2 deletions app-back/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ var currentGameData = null;
var tray = null;
var mainWindowHidden = false;

const canOpenApplication = app.requestSingleInstanceLock()
if (!canOpenApplication) app.quit();

Store.initRenderer();
app.commandLine.appendSwitch("enable-features", "OverlayScrollbar");
app.commandLine.appendSwitch("enable-threaded-compositing");
Expand Down Expand Up @@ -91,10 +94,13 @@ function createWindows() {
}
});
appWindow.on('show', () => {
tray.destroy();
if(tray) tray.destroy();
mainWindowHidden = true;
});

const log = require("electron-log")
log.transports.file.level = "debug"
autoUpdater.logger = log;
autoUpdater.autoDownload = false;
autoUpdater.checkForUpdatesAndNotify();
autoUpdater.on('update-available', () => {
Expand Down Expand Up @@ -159,6 +165,12 @@ function showOverlay() {

app.on("ready", () => globalShortcut.register("Shift+Backspace", showOverlay));

app.on('second-instance', (_event, _commandLine, _workingDirectory) => {
if(!appWindow) return;
appWindow.show();
appWindow.focus();
});

let isClosing = false;
app.on("before-quit", () => {
isClosing = true;
Expand All @@ -183,7 +195,7 @@ ipcMain.handle("get-bin-path", (_, __) => app.isPackaged ? path.join(process.res
ipcMain.handle("open-file-dialog", async (_) => (await dialog.showOpenDialog({properties:["openFile"]})).filePaths[0]);
ipcMain.handle("open-folder-dialog", async (_) => (await dialog.showOpenDialog({properties:["openDirectory"]})).filePaths[0]);
ipcMain.handle("gamechange", (_, arg) => currentGameData = arg);
ipcMain.handle('toggle-startup', (_, arg) => app.setLoginItemSettings({openAtLogin:arg,path:path.join(app.getPath('exe'),'/smoke.exe')}));
ipcMain.handle('toggle-startup', (_, arg) => app.setLoginItemSettings({openAtLogin:arg,path:app.getPath('exe')}));

const tempStorage = {};
ipcMain.handle("get-session-storage", (_, arg) => {
Expand Down
18 changes: 16 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
},
"dependencies": {
"@equal-games/game-scanner": "1.1.4",
"electron-log": "^5.0.3",
"electron-store": "~8.1.0",
"electron-updater": "~6.1.7",
"extract-zip": "2.0.1",
Expand Down

0 comments on commit cb393e9

Please sign in to comment.