Changed handlers and removed old listeners

Fixed on-close to work correctly on quit
This commit is contained in:
Core 2022-01-30 16:17:29 +00:00
parent 0ab0bd7b77
commit d80bfc8398
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
2 changed files with 47 additions and 46 deletions

View file

@ -330,11 +330,6 @@ export class Win {
event.returnValue = this.devMode;
});
electron.ipcMain.on("close", () => {
// listen for close event
this.win.close();
});
electron.ipcMain.on("put-library-songs", (event, arg) => {
fs.writeFileSync(
path.join(this.paths.ciderCache, "library-songs.json"),
@ -415,8 +410,8 @@ export class Win {
return await yt.search(u);
});
electron.ipcMain.handle("setVibrancy", (event, key, value) => {
this.win.setVibrancy(value);
electron.ipcMain.on("close", () => {
this.win.close();
});
electron.ipcMain.on("maximize", () => {
@ -555,6 +550,25 @@ export class Win {
});
}
let isQuiting = false
this.win.on("close", (event: Event) => {
if ((this.store.general.close_button_hide || process.platform === "darwin" )&& !isQuiting) {
event.preventDefault();
this.win.hide();
} else {
this.win.destroy();
}
})
electron.app.on('before-quit', () => {
isQuiting = true
});
electron.app.on('window-all-closed', () => {
electron.app.quit()
})
this.win.on("closed", () => {
this.win = null;
});
@ -568,6 +582,7 @@ export class Win {
return {action: "deny"};
});
}
private async broadcastRemote() {
function getIp() {
let ip: any = false;
@ -590,6 +605,7 @@ export class Win {
}
return ip;
}
const myString = `http://${getIp()}:${this.remotePort}`;
let mdns = require('mdns-js');
const encoded = new Buffer(myString).toString('base64');

View file

@ -3473,22 +3473,7 @@ const app = new Vue({
}
},
closeWindow(){
switch (app.cfg.general.close_behavior) {
case 0:
case '0':
// the minimizeToTray plugin will handle this
window.close();
break;
case 1:
case '1':
ipcRenderer.send('minimize');
break;
case 2:
case '2':
ipcRenderer.send('minimizeTray');
break;
}
ipcRenderer.send('close');
}
}