From 343de27cad215a4fe40a513fabfaf62207bf730b Mon Sep 17 00:00:00 2001 From: Lotus CI Date: Wed, 23 Sep 2026 19:48:23 -0400 Subject: [PATCH] feat(desktop): toast "Mark as read" marks the room read (cinny-desktop #9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handles the native `lotus-notification-mark-read` event through the same `markAsRead` path as the room menu's "Mark as Read", honouring the private-receipt settings. Verified: 3 unread → 0 on the server. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA --- src/app/hooks/useTauriToastActions.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/app/hooks/useTauriToastActions.ts b/src/app/hooks/useTauriToastActions.ts index dc38b70d0..a967a3358 100644 --- a/src/app/hooks/useTauriToastActions.ts +++ b/src/app/hooks/useTauriToastActions.ts @@ -5,6 +5,9 @@ import { Icons } from 'folds'; import { useMatrixClient } from './useMatrixClient'; import { useTauriEvent } from './useTauri'; import { createErrorToast, toastQueueAtom } from '../state/toast'; +import { useSetting } from '../state/hooks/settings'; +import { settingsAtom } from '../state/settings'; +import { markAsRead } from '../utils/notifications'; /** Payload of the `lotus-notification-activate` event (a plain body click). */ interface ActivateDetail { @@ -19,6 +22,11 @@ interface ReplyDetail { text?: string; } +/** Payload of the `lotus-notification-mark-read` event (the Mark as read button). */ +interface MarkReadDetail { + roomId?: string; +} + /** * P5-41 / P5-35 — wire the native WinRT toast's click + quick-reply back into the * client. The Rust side (`show_rich_toast`) dispatches DOM CustomEvents via @@ -27,12 +35,15 @@ interface ReplyDetail { * the same `useNavigate(path)` mechanism the web `notificationclick` path uses * (see ClientNonUIFeatures). * - `lotus-notification-reply` → send the typed reply straight to the room. + * - `lotus-notification-mark-read` → mark the room read, the same path as the + * room menu's "Mark as Read" (cinny-desktop #9). * No-op outside Tauri (the events never fire). */ export function useTauriToastActions(): void { const navigate = useNavigate(); const mx = useMatrixClient(); const setToast = useSetAtom(toastQueueAtom); + const [hideActivity] = useSetting(settingsAtom, 'hideActivity'); useTauriEvent('lotus-notification-activate', ({ path }) => { if (path) navigate(path); @@ -55,4 +66,8 @@ export function useTauriToastActions(): void { ); }); }); + + useTauriEvent('lotus-notification-mark-read', ({ roomId }) => { + if (roomId) markAsRead(mx, roomId, hideActivity).catch(() => undefined); + }); }