Clear cache on event update

This commit is contained in:
7w1 committed 2026-02-24 12:10:38 -06:00
1 parent 8bf202a9fb
commit f7331ddda8
2 files changed
+25

No files matched your search

+4
View File
@@ -1,5 +1,9 @@
# Sable Client Changelog
## Version 1.0.2 - in dev
- Global profile cache & automatic cache clearing on member update events.
## Version 1.0.1
- (potentially) fixed rare crash when changing rooms
+21
View File
@@ -23,6 +23,7 @@ import {
Room,
RoomEvent,
RoomEventHandlerMap,
RoomStateEvent,
} from 'matrix-js-sdk';
import { HTMLReactParserOptions } from 'html-react-parser';
import classNames from 'classnames';
@@ -966,6 +967,26 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
});
}, [timeline.range, timeline.linkedTimelines, mx, profileCache, getItems, globalProfiles, setGlobalProfiles]);
useEffect(() => {
const onMemberEvent = (event: MatrixEvent) => {
if (event.getType() !== StateEvent.RoomMember) return;
const userId = event.getStateKey();
if (!userId) return;
setGlobalProfiles((prev) => {
const next = { ...prev };
delete next[userId];
return next;
});
};
mx.on(RoomStateEvent.Members, onMemberEvent);
return () => {
mx.removeListener(RoomStateEvent.Members, onMemberEvent);
};
}, [mx, setGlobalProfiles]);
const handleJumpToLatest = () => {
if (eventId) {
navigateRoom(room.roomId, undefined, { replace: true });