Skip to content

Commit

Permalink
fix: electron freezing after closing dialog, or exiting after the ip …
Browse files Browse the repository at this point in the history
…prompt
  • Loading branch information
Julusian committed Jan 20, 2021
1 parent 17835bf commit 7b0bad2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "companion-remote",
"version": "0.1.0",
"version": "0.1.1-0",
"description": "Remote Streamdeck connector for Bitfocus Companion",
"author": {
"name": "Julian Waller",
Expand Down Expand Up @@ -45,7 +45,7 @@
"@julusian/jpeg-turbo": "^1.0.1",
"binopsy": "^0.0.0",
"electron-about-window": "^1.13.4",
"electron-prompt": "^1.6.0",
"electron-prompt": "https://github.com/Julusian/electron-prompt.git#fix/cancel-exits-app",
"electron-store": "^6.0.1",
"elgato-stream-deck": "^4.0.1",
"eventemitter3": "^4.0.7",
Expand Down
32 changes: 23 additions & 9 deletions src/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import openAboutWindow from 'electron-about-window'

const store = new electronStore<RemoteConfig>()

app.on('window-all-closed', () => {
// Block default behaviour of exit on close
})

interface RemoteConfig {
remoteIp: string
}
Expand Down Expand Up @@ -64,15 +68,19 @@ function changeHost() {
value: current ?? '127.0.0.1',
inputAttrs: {},
type: 'input',
}).then((r) => {
if (r === null) {
console.log('user cancelled')
} else {
console.log('result', r)
store.set('remoteIp', r)
client.connect(r)
}
})
.then((r) => {
if (r === null) {
console.log('user cancelled')
} else {
console.log('new ip', r)
store.set('remoteIp', r)
client.connect(r)
}
})
.catch((e) => {
console.error('Failed to change host', e)
})
}

function trayQuit() {
Expand All @@ -89,15 +97,21 @@ function trayQuit() {
app.quit()
}
})
.catch((e) => {
console.error('Failed to do quit', e)
})
}

function trayAbout() {
console.log('about click')
openAboutWindow({
icon_path: path.join(__dirname, '../assets', 'icon.png'),
product_name: 'Companion Remote',
description: 'Remote Streamdeck connector for Bitfocus Companion 2.1.2 and newer',
description: 'Remote Streamdeck connector for Bitfocus Companion <br />Supports 2.1.2 and newer',
adjust_window_size: false,
win_options: {
resizable: false,
},
bug_report_url: 'https://github.com/julusian/companion-remote/issues',
copyright: '2021 Julian Waller',
homepage: 'https://github.com/julusian/companion-remote',
Expand Down
7 changes: 3 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1242,10 +1242,9 @@ electron-builder@^22.9.1:
update-notifier "^4.1.1"
yargs "^16.0.3"

electron-prompt@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/electron-prompt/-/electron-prompt-1.6.0.tgz#9ed8fa372c331c589f2cb5d3a6abf29d4965be31"
integrity sha512-CJaSo7o84JJygBGCHIY1zySn+j2ejsKZZFAmfIrOw8wgriufzl4RchTf9I2HNFvlOiekGj4WAznOaA6gFm5ddQ==
"electron-prompt@https://github.com/Julusian/electron-prompt.git#fix/cancel-exits-app":
version "0.0.0-dev"
resolved "https://github.com/Julusian/electron-prompt.git#1694b4bbf9ac9659c50a5fb61af3b47ed0407595"
dependencies:
doc-ready "^1.0.4"

Expand Down

0 comments on commit 7b0bad2

Please sign in to comment.