Get two instances to kinda work at the same time

This commit is contained in:
Jacob Karlsson 2024-04-14 22:20:42 +02:00
parent 9da1176e5f
commit 68c3b566c9
2 changed files with 19 additions and 17 deletions

30
main.js
View File

@ -20,7 +20,7 @@ na.sodium_free = function sodium_free_monkey_patched() {}
process.env.ZOOBOARD_DATA ??= Path.join(app.getPath('appData'), 'zooboard')
app.setPath('userData', process.env.ZOOBOARD_DATA)
const path = Path.resolve(app.getPath('userData'), 'ppppp')
const path = process.env.PZP_DIR ?? Path.resolve(app.getPath('userData'), 'ppppp')
const keypairPath = Path.join(path, 'keypair.json')
const keypair = Keypair.loadOrCreateSync(keypairPath)
@ -277,20 +277,20 @@ if (process.defaultApp) {
app.setAsDefaultProtocolClient('ppppp')
}
const hasLock = app.requestSingleInstanceLock()
//const hasLock = app.requestSingleInstanceLock()
if (!hasLock) {
app.quit()
} else {
app.on('second-instance', (ev, argv, cwd, extraData) => {
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.focus()
if (argv.length > 1) {
handlePPPPPUri(null, argv[argv.length - 1])
}
}
})
//if (!hasLock) {
// app.quit()
//} else {
// app.on('second-instance', (ev, argv, cwd, extraData) => {
// if (mainWindow) {
// if (mainWindow.isMinimized()) mainWindow.restore()
// mainWindow.focus()
// if (argv.length > 1) {
// handlePPPPPUri(null, argv[argv.length - 1])
// }
// }
// })
app.whenReady().then(() => {
ipcMain.handle('loadAccount', loadAccount)
@ -313,4 +313,4 @@ if (!hasLock) {
if (process.platform !== 'darwin') app.quit()
})
})
}
//}

View File

@ -5,11 +5,13 @@
"main": "main.js",
"homepage": "./",
"scripts": {
"start": "BROWSER=none react-scripts start",
"start": "PORT=3001 BROWSER=none react-scripts start",
"start2": "PZP_DIR=/tmp/zooboard-test PORT=3002 BROWSER=none react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"electron": "ELECTRON_START_URL=http://localhost:3000 DEBUG=*,-shse,-pull-secretstream electron ."
"electron": "ELECTRON_START_URL=http://localhost:3001 DEBUG=*,-shse,-pull-secretstream electron .",
"electron2": "PZP_DIR=/tmp/zooboard-test ELECTRON_START_URL=http://localhost:3002 DEBUG=*,-shse,-pull-secretstream electron ."
},
"dependencies": {
"@excalidraw/excalidraw": "0.17.2",