Force disable minimise if tray is hidden

This commit is contained in:
TheKodeToad 2023-04-09 23:03:56 +01:00
parent 9c75d31895
commit ff87db66d7
2 changed files with 8 additions and 6 deletions

View file

@ -246,7 +246,7 @@ export function createMainWindow() {
}));
win.on("close", e => {
if (isQuitting || Settings.store.minimizeToTray === false) return;
if (isQuitting || Settings.store.minimizeToTray === false || Settings.store.tray === false) return;
e.preventDefault();
win.hide();
@ -255,7 +255,7 @@ export function createMainWindow() {
});
initWindowBoundsListeners(win);
if (Settings.tray !== false) initTray(win);
if (Settings.store.tray ?? true) initTray(win);
initMenuBar(win);
makeLinksOpenExternally(win);
initSettingsListeners(win);

View file

@ -21,7 +21,7 @@ export default function SettingsUi() {
Button
} = Common;
const switches: [keyof typeof Settings, string, string, boolean?][] = [
const switches: [keyof typeof Settings, string, string, boolean?, (() => boolean)?][] = [
[
"tray",
"Use tray",
@ -32,7 +32,8 @@ export default function SettingsUi() {
"minimizeToTray",
"Minimize to tray",
"Hitting X will make Vencord Desktop minimize to the tray instead of closing",
true
true,
() => Settings["tray"] ?? true
],
[
"disableMinSize",
@ -68,9 +69,10 @@ export default function SettingsUi() {
<FormDivider className={Margins.top16 + " " + Margins.bottom16} />
{switches.map(([key, text, note, def]) => (
{switches.map(([key, text, note, def, predicate]) => (
<FormSwitch
value={Settings[key] ?? def ?? false}
value={(Settings[key] ?? def ?? false) && (!predicate || predicate())}
disabled={predicate && !predicate()}
onChange={v => (Settings[key] = v)}
note={note}
key={key}