From 49e9cff8170b238ef1a07b5f270d8bcc6d7db685 Mon Sep 17 00:00:00 2001 From: Diego Parra Date: Wed, 20 Mar 2024 20:56:05 +0100 Subject: [PATCH] Update trayClickHandler and settings entry - Renamed to onTrayClick. - Refactor handler function into a single callback. - Update settings entry to reflect not needing a full restart anymore. This commit addresses the proposed changes from @Vendicated vendicated@riseup.net --- src/main/mainWindow.ts | 13 +++++-------- src/renderer/components/settings/Settings.tsx | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 26e0058..7e0afde 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -73,13 +73,10 @@ const [addSettingsListener, removeSettingsListeners] = makeSettingsListenerHelpe const [addVencordSettingsListener, removeVencordSettingsListeners] = makeSettingsListenerHelpers(VencordSettings); function initTray(win: BrowserWindow) { - const trayClickHandler = Settings.store.clickTrayToShowHide - ? () => { - win.isVisible() ? win.hide() : win.show(); - } - : () => { - win.show(); - }; + const onTrayClick = () => { + if (Settings.store.clickTrayToShowHide && win.isVisible()) win.hide(); + else win.show(); + }; const trayMenu = Menu.buildFromTemplate([ { label: "Open", @@ -127,7 +124,7 @@ function initTray(win: BrowserWindow) { tray = new Tray(ICON_PATH); tray.setToolTip("Vesktop"); tray.setContextMenu(trayMenu); - tray.on("click", trayClickHandler); + tray.on("click", onTrayClick); } async function clearData(win: BrowserWindow) { diff --git a/src/renderer/components/settings/Settings.tsx b/src/renderer/components/settings/Settings.tsx index b20347c..d6de13c 100644 --- a/src/renderer/components/settings/Settings.tsx +++ b/src/renderer/components/settings/Settings.tsx @@ -85,8 +85,8 @@ const SettingsOptions: Record> }, { key: "clickTrayToShowHide", - title: "Hide/Show on tray left click", - description: "Left clicking on tray will hide or show the vesktop window. Requires a full restart.", + title: "Hide/Show on tray click", + description: "Left clicking tray icon will toggle the vesktop window visibility.", defaultValue: false }, {