enable disabling tray

This commit is contained in:
Kendall Garner 2024-09-08 20:55:07 -07:00
parent 74aa88e082
commit 1b41a5a674
No known key found for this signature in database
GPG key ID: 18D2767419676C87
4 changed files with 55 additions and 5 deletions

View file

@ -81,11 +81,55 @@ export const WindowSettings = () => {
isHidden: !isElectron(),
title: t('setting.windowBarStyle', { postProcess: 'sentenceCase' }),
},
{
control: (
<Switch
aria-label="toggle hiding tray"
defaultChecked={settings.tray}
disabled={!isElectron()}
onChange={(e) => {
if (!e) return;
localSettings?.set('window_enable_tray', e.currentTarget.checked);
if (e.currentTarget.checked) {
setSettings({
window: {
...settings,
tray: true,
},
});
} else {
localSettings?.set('window_start_minimized', false);
localSettings?.set('window_exit_to_tray', false);
localSettings?.set('window_minimize_to_tray', false);
setSettings({
window: {
...settings,
exitToTray: false,
minimizeToTray: false,
startMinimized: false,
tray: false,
},
});
}
}}
/>
),
description: t('setting.trayEnabled', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
note: t('common.restartRequired', {
postProcess: 'sentenceCase',
}),
title: t('setting.trayEnabled', { postProcess: 'sentenceCase' }),
},
{
control: (
<Switch
aria-label="Toggle minimize to tray"
defaultChecked={settings.minimizeToTray}
defaultChecked={settings.tray}
disabled={!isElectron()}
onChange={(e) => {
if (!e) return;
@ -103,7 +147,7 @@ export const WindowSettings = () => {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
isHidden: !isElectron() || !settings.tray,
title: t('setting.minimizeToTray', { postProcess: 'sentenceCase' }),
},
{
@ -128,7 +172,7 @@ export const WindowSettings = () => {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
isHidden: !isElectron() || !settings.tray,
title: t('setting.exitToTray', { postProcess: 'sentenceCase' }),
},
{
@ -153,7 +197,7 @@ export const WindowSettings = () => {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
isHidden: !isElectron() || !settings.tray,
title: t('setting.startMinimized', { postProcess: 'sentenceCase' }),
},
];

View file

@ -313,6 +313,7 @@ export interface SettingsState {
exitToTray: boolean;
minimizeToTray: boolean;
startMinimized: boolean;
tray: boolean;
windowBarStyle: Platform;
};
}
@ -647,6 +648,7 @@ const initialState: SettingsState = {
exitToTray: false,
minimizeToTray: false,
startMinimized: false,
tray: true,
windowBarStyle: platformDefaultWindowBarStyle,
},
};