chore(client): mount search-cache invalidation; reminder toast resolves text locally
Wires useSearchCacheInvalidation (#14) and makes ReminderMonitor derive the toast body from the local event when the stored reminder carries no text (#10). Refs #10 Refs #14 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -26,6 +26,7 @@ import { settingsAtom } from '../../state/settings';
|
|||||||
import { allInvitesAtom } from '../../state/room-list/inviteList';
|
import { allInvitesAtom } from '../../state/room-list/inviteList';
|
||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
import { useHydrateMsgDrafts } from '../../hooks/useHydrateMsgDrafts';
|
import { useHydrateMsgDrafts } from '../../hooks/useHydrateMsgDrafts';
|
||||||
|
import { useSearchCacheInvalidation } from '../../utils/searchCacheInvalidation';
|
||||||
import {
|
import {
|
||||||
getDirectRoomPath,
|
getDirectRoomPath,
|
||||||
getHomeRoomPath,
|
getHomeRoomPath,
|
||||||
@@ -722,14 +723,23 @@ function ReminderMonitor() {
|
|||||||
if (!firedRef.current.has(key)) {
|
if (!firedRef.current.has(key)) {
|
||||||
firedRef.current.add(key);
|
firedRef.current.add(key);
|
||||||
const room = mx.getRoom(r.roomId);
|
const room = mx.getRoom(r.roomId);
|
||||||
|
const roomName = room?.name ?? 'Unknown Room';
|
||||||
|
// Reminders for E2EE rooms carry no text (account data is server-
|
||||||
|
// readable), so resolve the body from the local timeline at fire time.
|
||||||
|
const localBody = room?.findEventById(r.eventId)?.getContent()?.body;
|
||||||
|
const body =
|
||||||
|
r.message ??
|
||||||
|
(typeof localBody === 'string' && localBody
|
||||||
|
? localBody.slice(0, 120)
|
||||||
|
: `Reminder for a message in ${roomName}`);
|
||||||
const hashPath = mDirectsRef.current.has(r.roomId)
|
const hashPath = mDirectsRef.current.has(r.roomId)
|
||||||
? getDirectRoomPath(r.roomId, r.eventId)
|
? getDirectRoomPath(r.roomId, r.eventId)
|
||||||
: getHomeRoomPath(r.roomId, r.eventId);
|
: getHomeRoomPath(r.roomId, r.eventId);
|
||||||
setToast({
|
setToast({
|
||||||
id: `reminder-${key}`,
|
id: `reminder-${key}`,
|
||||||
displayName: 'Reminder',
|
displayName: 'Reminder',
|
||||||
body: r.message,
|
body,
|
||||||
roomName: room?.name ?? 'Unknown Room',
|
roomName,
|
||||||
roomId: r.roomId,
|
roomId: r.roomId,
|
||||||
hashPath,
|
hashPath,
|
||||||
});
|
});
|
||||||
@@ -896,10 +906,18 @@ function MsgDraftHydrator(): null {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gitea #14 — keeps the opt-in persistent search cache from outliving the
|
||||||
|
// plaintext it indexed (redactions + leaving/being banned from a room).
|
||||||
|
function SearchCacheInvalidationFeature(): null {
|
||||||
|
useSearchCacheInvalidation();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export function ClientNonUIFeatures({ children }: ClientNonUIFeaturesProps) {
|
export function ClientNonUIFeatures({ children }: ClientNonUIFeaturesProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MsgDraftHydrator />
|
<MsgDraftHydrator />
|
||||||
|
<SearchCacheInvalidationFeature />
|
||||||
<SystemEmojiFeature />
|
<SystemEmojiFeature />
|
||||||
<PageZoomFeature />
|
<PageZoomFeature />
|
||||||
<FaviconUpdater />
|
<FaviconUpdater />
|
||||||
|
|||||||
Reference in New Issue
Block a user