Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src-tauri/capabilities/desktop.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "desktop",
"description": "desktop-only permissions: in-app auto-update and restart",
"description": "desktop-only permissions: in-app auto-update, restart and quit",
"windows": [
"main"
],
"platforms": ["macOS", "windows", "linux"],
"permissions": [
"updater:default",
"process:allow-restart"
"process:allow-restart",
"process:allow-exit"
]
}
4 changes: 1 addition & 3 deletions src/hooks/useDesktopTray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export function useDesktopTray(): void {
shownKey = key;
void showUnreadState(level, mentions);
};
void createDesktopTray(
() => useStore.getState().globalSettings.closeToTray,
).then(() => update(useStore.getState()));
void createDesktopTray().then(() => update(useStore.getState()));
return useStore.subscribe(update);
}, []);
}
2 changes: 1 addition & 1 deletion src/hooks/useMessageSending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export function useMessageSending({
const [commandName, ...args] = command.split(" ");

if (commandName === "nick") {
ircClient.sendRaw(selectedServerId, `NICK ${args[0]}`);
if (args[0]) useStore.getState().changeNick(selectedServerId, args[0]);
} else if (commandName === "join") {
const [channels, keyList] = args.filter(Boolean);
if (channels) {
Expand Down
29 changes: 14 additions & 15 deletions src/lib/desktopTray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Image } from "@tauri-apps/api/image";
import { Menu } from "@tauri-apps/api/menu";
import { TrayIcon } from "@tauri-apps/api/tray";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { exit } from "@tauri-apps/plugin-process";
import type { Server } from "../types";

export type UnreadLevel = "none" | "unread" | "mention";
Expand Down Expand Up @@ -68,27 +69,29 @@ let trayCreation: Promise<void> | null = null;
let baseIcon: Image | null = null;
const dottedIcons = new Map<UnreadLevel, Image>();

/** Creates the tray icon with its menu once per app, and hides the window on
* close while `shouldCloseToTray` says so. */
export function createDesktopTray(
shouldCloseToTray: () => boolean,
): Promise<void> {
trayCreation ??= buildTray(shouldCloseToTray);
// We end the whole process, since any other window left open keeps the app running.
const quitApp = () => void exit(0);

/** Creates the tray icon with its menu once per app. Closing the window quits
* the app, and the tray menu hides it to the tray instead. */
export function createDesktopTray(): Promise<void> {
trayCreation ??= buildTray();
return trayCreation;
}

async function buildTray(shouldCloseToTray: () => boolean): Promise<void> {
async function buildTray(): Promise<void> {
// The tray outlives a page reload but its menu callbacks do not, so we replace it.
await (await TrayIcon.getById(TRAY_ID))?.close();
baseIcon = await defaultWindowIcon();
const menu = await Menu.new({
items: [
{ id: "show", text: t`Show Obby`, action: () => void showMainWindow() },
{
id: "quit",
text: t`Quit Obby`,
action: () => void getCurrentWindow().destroy(),
id: "hide",
text: t`Minimize to tray`,
action: () => void getCurrentWindow().hide(),
},
{ id: "quit", text: t`Quit Obby`, action: quitApp },
],
});
tray = await TrayIcon.new({
Expand All @@ -106,11 +109,7 @@ async function buildTray(shouldCloseToTray: () => boolean): Promise<void> {
void showMainWindow();
},
});
await getCurrentWindow().onCloseRequested((event) => {
if (!shouldCloseToTray()) return;
event.preventDefault();
void getCurrentWindow().hide();
});
await getCurrentWindow().onCloseRequested(quitApp);
}

async function iconFor(level: UnreadLevel): Promise<Image | null> {
Expand Down
19 changes: 1 addition & 18 deletions src/lib/settings/definitions/allSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import { CustomMentionsField } from "../../../components/ui/settings/CustomMenti
import { HistoryUsageField } from "../../../components/ui/settings/HistoryUsageField";
import { IgnoreListField } from "../../../components/ui/settings/IgnoreListField";
import { PushMethodField } from "../../../components/ui/settings/PushMethodField";
import {
isTauriAndroid,
isTauriDesktop,
isTauriIOS,
} from "../../platformUtils";
import { isTauriAndroid, isTauriIOS } from "../../platformUtils";
import settingsRegistry from "../registry";
import type { SettingDefinition } from "../types";

Expand Down Expand Up @@ -188,19 +184,6 @@ const notificationSettings: SettingDefinition[] = [
searchKeywords: ["notification", "alert", "desktop", "push", "banner"],
priority: 0,
},
{
id: "notifications.closeToTray",
key: "closeToTray",
category: "notifications",
subcategory: "Alerts",
title: msg`Keep Running in the Tray`,
description: msg`Closing the window keeps Obby connected in the system tray, so notifications still arrive`,
type: "toggle",
defaultValue: true,
hidden: !isTauriDesktop(),
searchKeywords: ["tray", "background", "close", "minimize", "menu bar"],
priority: 0,
},
{
id: "notifications.pushMethod",
key: "pushMethod",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/cs/messages.mjs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/locales/cs/messages.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/locales/de/messages.mjs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/locales/de/messages.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/locales/en/messages.mjs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/locales/en/messages.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/locales/es/messages.mjs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/locales/es/messages.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/locales/fi/messages.mjs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/locales/fi/messages.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/locales/fr/messages.mjs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/locales/fr/messages.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/locales/it/messages.mjs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/locales/it/messages.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/locales/ja/messages.mjs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/locales/ja/messages.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/locales/ko/messages.mjs

Large diffs are not rendered by default.

Loading
Loading