From af200920537b2a2a733d3c9818894bf92ff1349d Mon Sep 17 00:00:00 2001 From: Mastermindzh Date: Sat, 22 Apr 2023 20:51:20 +0200 Subject: [PATCH] fix: fixed tray click bug. fixes #196 --- CHANGELOG.md | 2 ++ build/electron-builder.base.yml | 5 ++--- package-lock.json | 4 ++-- package.json | 2 +- src/main.js | 3 ++- src/scripts/tray.js | 10 +++++++++- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 144740b..3b16f83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Replaced "muting artists" with a full implementation of an Adblock mechanism > Disabled audio & visual ads, unlocked lyrics, suggested track, track info, unlimited skips thanks to uBlockOrigin custom filters ([source](https://github.com/uBlockOrigin/uAssets/issues/17495)) +- @thanasistrisp updated Electron to 24.1.2 and fixed the tray bug :) + ## 4.4.0 - Updated shortcut hint on the menubar to reflect the new `ctrl+=` shortcut. diff --git a/build/electron-builder.base.yml b/build/electron-builder.base.yml index 206adfa..8fbe577 100644 --- a/build/electron-builder.base.yml +++ b/build/electron-builder.base.yml @@ -1,8 +1,7 @@ appId: com.rickvanlieshout.tidal-hifi -electronVersion: 19.0.5 +electronVersion: 24.1.2 electronDownload: - version: 19.0.5+wvcus - mirror: https://github.com/castlabs/electron-releases/releases/download/v + version: 24.1.2+wvcus snap: plugs: - default diff --git a/package-lock.json b/package-lock.json index dc8d47c..756ca0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ }, "devDependencies": { "@mastermindzh/prettier-config": "^1.0.0", - "electron": "git+https://github.com/castlabs/electron-releases.git#v19.0.5+wvcus", + "electron": "git+https://github.com/castlabs/electron-releases.git#v24.1.2+wvcus", "electron-builder": "^24.2.1", "js-yaml": "^3.14.1", "markdown-toc": "^1.2.0", @@ -10197,7 +10197,7 @@ }, "electron": { "version": "git+ssh://git@github.com/castlabs/electron-releases.git#b7e63c1416bbebfb25a5eddebd2049d65996ff26", - "from": "electron@git+https://github.com/castlabs/electron-releases.git#v19.0.5+wvcus", + "from": "electron@git+https://github.com/castlabs/electron-releases.git#v24.1.2+wvcus", "requires": { "@electron/get": "^1.14.1", "@types/node": "^16.11.26", diff --git a/package.json b/package.json index 68c182f..7226440 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@mastermindzh/prettier-config": "^1.0.0", - "electron": "git+https://github.com/castlabs/electron-releases.git#v19.0.5+wvcus", + "electron": "git+https://github.com/castlabs/electron-releases.git#v24.1.2+wvcus", "electron-builder": "^24.2.1", "js-yaml": "^3.14.1", "markdown-toc": "^1.2.0", diff --git a/src/main.js b/src/main.js index 42a8ae9..4004555 100644 --- a/src/main.js +++ b/src/main.js @@ -91,6 +91,7 @@ function createWindow(options = {}) { backgroundColor: options.backgroundColor, autoHideMenuBar: true, webPreferences: { + sandbox: false, preload: path.join(__dirname, "preload.js"), plugins: true, devTools: true, // I like tinkering, others might too @@ -159,7 +160,7 @@ app.on("ready", async () => { if (store.get(settings.adBlock)) { const filter = { urls: ["https://listen.tidal.com/*"] }; session.defaultSession.webRequest.onBeforeRequest(filter, (details, callback) => { - if (details.url.match(/\d\?country/)) callback({ cancel: true }); + if (details.url.match(/\/users\/.*\d\?country/)) callback({ cancel: true }); else callback({ cancel: false }); }); } diff --git a/src/scripts/tray.js b/src/scripts/tray.js index 0000fe5..ab0fdc2 100644 --- a/src/scripts/tray.js +++ b/src/scripts/tray.js @@ -13,7 +13,15 @@ trayModule.addTray = function (mainWindow, options = { icon: "" }) { tray.setContextMenu(menu); tray.on("click", function () { - mainWindow.isVisible() ? mainWindow.focus() : mainWindow.show(); + if (mainWindow.isVisible()) { + if (!mainWindow.isFocused()) { + mainWindow.focus(); + } else { + mainWindow.hide(); + } + } else { + mainWindow.show(); + } }); };