mirror of
https://github.com/desktop/desktop
synced 2024-09-19 16:12:20 +00:00
Merge pull request #35 from desktop/single-instance
manage single instance of desktop app
This commit is contained in:
commit
f8689057e8
|
@ -53,6 +53,18 @@ export default class AppWindow {
|
||||||
this.send('url-action', action)
|
this.send('url-action', action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isMinimized() {
|
||||||
|
return this.window.isMinimized()
|
||||||
|
}
|
||||||
|
|
||||||
|
public restore() {
|
||||||
|
this.window.restore()
|
||||||
|
}
|
||||||
|
|
||||||
|
public focus() {
|
||||||
|
this.window.focus()
|
||||||
|
}
|
||||||
|
|
||||||
private rendererLog(msg: string) {
|
private rendererLog(msg: string) {
|
||||||
this.send('log', msg)
|
this.send('log', msg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,29 @@ app.on('will-finish-launching', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
|
||||||
|
// Someone tried to run a second instance, we should focus our window.
|
||||||
|
if (mainWindow) {
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore()
|
||||||
|
}
|
||||||
|
mainWindow.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
// look at the second argument received, it should have the OAuth
|
||||||
|
// callback contents and code for us to complete the signin flow
|
||||||
|
if (commandLine.length > 1) {
|
||||||
|
const action = parseURL(commandLine[1])
|
||||||
|
mainWindow.sendURLAction(action)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (shouldQuit) {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
stats.readyTime = Date.now()
|
stats.readyTime = Date.now()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue