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
This commit is contained in:
Diego Parra 2024-03-20 20:56:05 +01:00
parent 38e6ebe0d2
commit 49e9cff817
2 changed files with 7 additions and 10 deletions

View file

@ -73,13 +73,10 @@ const [addSettingsListener, removeSettingsListeners] = makeSettingsListenerHelpe
const [addVencordSettingsListener, removeVencordSettingsListeners] = makeSettingsListenerHelpers(VencordSettings); const [addVencordSettingsListener, removeVencordSettingsListeners] = makeSettingsListenerHelpers(VencordSettings);
function initTray(win: BrowserWindow) { function initTray(win: BrowserWindow) {
const trayClickHandler = Settings.store.clickTrayToShowHide const onTrayClick = () => {
? () => { if (Settings.store.clickTrayToShowHide && win.isVisible()) win.hide();
win.isVisible() ? win.hide() : win.show(); else win.show();
} };
: () => {
win.show();
};
const trayMenu = Menu.buildFromTemplate([ const trayMenu = Menu.buildFromTemplate([
{ {
label: "Open", label: "Open",
@ -127,7 +124,7 @@ function initTray(win: BrowserWindow) {
tray = new Tray(ICON_PATH); tray = new Tray(ICON_PATH);
tray.setToolTip("Vesktop"); tray.setToolTip("Vesktop");
tray.setContextMenu(trayMenu); tray.setContextMenu(trayMenu);
tray.on("click", trayClickHandler); tray.on("click", onTrayClick);
} }
async function clearData(win: BrowserWindow) { async function clearData(win: BrowserWindow) {

View file

@ -85,8 +85,8 @@ const SettingsOptions: Record<string, Array<BooleanSetting | SettingsComponent>>
}, },
{ {
key: "clickTrayToShowHide", key: "clickTrayToShowHide",
title: "Hide/Show on tray left click", title: "Hide/Show on tray click",
description: "Left clicking on tray will hide or show the vesktop window. Requires a full restart.", description: "Left clicking tray icon will toggle the vesktop window visibility.",
defaultValue: false defaultValue: false
}, },
{ {