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:
parent
38e6ebe0d2
commit
49e9cff817
2 changed files with 7 additions and 10 deletions
|
@ -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) {
|
||||
|
|
|
@ -85,8 +85,8 @@ const SettingsOptions: Record<string, Array<BooleanSetting | SettingsComponent>>
|
|||
},
|
||||
{
|
||||
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
|
||||
},
|
||||
{
|
||||
|
|
Reference in a new issue