mirror of
https://github.com/bitwarden/browser
synced 2025-01-23 01:33:02 +01:00
Fix dock icon not working when minimized to menu bar, fix window listeners not working after closing the main window (#223)
This commit is contained in:
parent
ecf1edfb3e
commit
63fe38b3f4
@ -1,5 +1,6 @@
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
Menu,
|
||||
MenuItem,
|
||||
MenuItemConstructorOptions,
|
||||
@ -57,15 +58,17 @@ export class TrayMain {
|
||||
if (await this.storageService.get<boolean>(ElectronConstants.enableTrayKey)) {
|
||||
this.showTray();
|
||||
}
|
||||
}
|
||||
|
||||
this.windowMain.win.on('minimize', async (e: Event) => {
|
||||
setupWindowListeners(win: BrowserWindow) {
|
||||
win.on('minimize', async (e: Event) => {
|
||||
if (await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey)) {
|
||||
e.preventDefault();
|
||||
this.hideToTray();
|
||||
}
|
||||
});
|
||||
|
||||
this.windowMain.win.on('close', async (e: Event) => {
|
||||
win.on('close', async (e: Event) => {
|
||||
if (await this.storageService.get<boolean>(ElectronConstants.enableCloseToTrayKey)) {
|
||||
if (!this.windowMain.isQuitting) {
|
||||
e.preventDefault();
|
||||
@ -74,7 +77,7 @@ export class TrayMain {
|
||||
}
|
||||
});
|
||||
|
||||
this.windowMain.win.on('show', async (e: Event) => {
|
||||
win.on('show', async (e: Event) => {
|
||||
const enableTray = await this.storageService.get<boolean>(ElectronConstants.enableTrayKey);
|
||||
if (!enableTray) {
|
||||
setTimeout(() => this.removeTray(false), 100);
|
||||
|
@ -23,7 +23,8 @@ export class WindowMain {
|
||||
|
||||
constructor(private storageService: StorageService, private hideTitleBar = false,
|
||||
private defaultWidth = 950, private defaultHeight = 600,
|
||||
private argvCallback: (argv: string[]) => void = null) { }
|
||||
private argvCallback: (argv: string[]) => void = null,
|
||||
private createWindowCallback: (win: BrowserWindow) => void) { }
|
||||
|
||||
init(): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -82,6 +83,9 @@ export class WindowMain {
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (this.win === null) {
|
||||
await this.createWindow();
|
||||
} else {
|
||||
// Show the window when clicking on Dock icon
|
||||
this.win.show();
|
||||
}
|
||||
});
|
||||
|
||||
@ -169,6 +173,9 @@ export class WindowMain {
|
||||
this.windowStateChangeHandler(Keys.mainWindowSize, this.win);
|
||||
});
|
||||
|
||||
if (this.createWindowCallback) {
|
||||
this.createWindowCallback(this.win);
|
||||
}
|
||||
}
|
||||
|
||||
async toggleAlwaysOnTop() {
|
||||
|
Loading…
Reference in New Issue
Block a user