feat(desktop): toast "Mark as read" marks the room read (cinny-desktop #9)
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3b6de2fdac
commit
343de27cad
@@ -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<ActivateDetail>('lotus-notification-activate', ({ path }) => {
|
||||
if (path) navigate(path);
|
||||
@@ -55,4 +66,8 @@ export function useTauriToastActions(): void {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
useTauriEvent<MarkReadDetail>('lotus-notification-mark-read', ({ roomId }) => {
|
||||
if (roomId) markAsRead(mx, roomId, hideActivity).catch(() => undefined);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user