git ssb

10+

Matt McKegg / patchwork



Commit fcc4d4dd295cf9fad639e12cd83d8030f311fda9

Merge pull request #704 from Happy0/window

Focus existing patchwork if it is already running. Fixes #703
Matt McKegg authored on 2/12/2018, 1:09:39 AM
GitHub committed on 2/12/2018, 1:09:39 AM
Parent: 122ab3c45058060aa304d66629e51a45dbcda3aa
Parent: ae310201bc0006d9868d9730b64042feb9cea984

Files changed

index.jschanged
index.jsView
@@ -18,8 +18,31 @@
1818 }
1919 var ssbConfig = null
2020 var quitting = false
2121
22+/**
23+ * It's not possible to run two instances of patchwork as it would create two
24+ * scuttlebot instances that conflict on the same port. Before opening patchwork,
25+ * we check if it's already running and if it is we focus the existing window
26+ * rather than opening a new instance.
27+ */
28+function quitIfAlreadyRunning() {
29+ var shouldQuit = electron.app.makeSingleInstance(function(commandLine, workingDirectory) {
30+ // Someone tried to run a second instance, we should focus our window.
31+ if (windows.main) {
32+ if (windows.main.isMinimized()) windows.main.restore();
33+ windows.main.focus();
34+ }
35+ });
36+
37+ if (shouldQuit) {
38+ electron.app.quit();
39+ return;
40+ }
41+}
42+
43+quitIfAlreadyRunning();
44+
2245 electron.app.on('ready', () => {
2346 setupContext('ssb', {
2447 server: !(process.argv.includes('-g') || process.argv.includes('--use-global-ssb'))
2548 }, () => {

Built with git-ssb-web