fix(desktop): surface native quick-reply send failures as an error toast

Fixes #79

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
2026-09-12 20:28:42 -04:00
co-authored by Claude Opus 5
parent 1a5ca81513
commit e96bd527a0
+16 -1
View File
@@ -1,7 +1,10 @@
import { useNavigate } from 'react-router-dom';
import { MsgType } from 'matrix-js-sdk';
import { useSetAtom } from 'jotai';
import { Icons } from 'folds';
import { useMatrixClient } from './useMatrixClient';
import { useTauriEvent } from './useTauri';
import { createErrorToast, toastQueueAtom } from '../state/toast';
/** Payload of the `lotus-notification-activate` event (a plain body click). */
interface ActivateDetail {
@@ -27,6 +30,7 @@ interface ReplyDetail {
export function useTauriToastActions(): void {
const navigate = useNavigate();
const mx = useMatrixClient();
const setToast = useSetAtom(toastQueueAtom);
useTauriEvent<ActivateDetail>('lotus-notification-activate', ({ path }) => {
if (path) navigate(path);
@@ -34,6 +38,17 @@ export function useTauriToastActions(): void {
useTauriEvent<ReplyDetail>('lotus-notification-reply', ({ roomId, text }) => {
if (!roomId || !text) return;
mx.sendMessage(roomId, { msgtype: MsgType.Text, body: text }).catch(() => undefined);
// #79 — a quick-reply failure (offline, no send permission, etc.) used to
// be swallowed with no feedback, leaving the user believing it was sent.
// Surface it via the in-app error toast instead.
mx.sendMessage(roomId, { msgtype: MsgType.Text, body: text }).catch(() => {
setToast(
createErrorToast(
'Your quick reply could not be sent. Please try again.',
Icons.Warning,
'Reply failed',
),
);
});
});
}