mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-01 22:32:32 -08:00
fix(timeline): refresh rows after decryption
This commit is contained in:
1 parent
dc67f854fd
commit
7bdb5af680
2 files changed
+40
No files matched your search
@@ -992,6 +992,32 @@ describe('live-arrive edge cases', () => {
|
||||
|
||||
expect(result.current.timeline).not.toBe(before);
|
||||
});
|
||||
|
||||
it('re-renders when an event finishes decrypting', async () => {
|
||||
const { room } = createRoom();
|
||||
const { result } = renderSyncHook(room);
|
||||
const before = result.current.timeline;
|
||||
|
||||
await act(async () => {
|
||||
mxEmitter.emit(MatrixEventEvent.Decrypted, { getRoomId: () => room.roomId });
|
||||
await Promise.resolve();
|
||||
});
|
||||
|
||||
expect(result.current.timeline).not.toBe(before);
|
||||
});
|
||||
|
||||
it('ignores decryption of an event in another room', async () => {
|
||||
const { room } = createRoom();
|
||||
const { result } = renderSyncHook(room);
|
||||
const before = result.current.timeline;
|
||||
|
||||
await act(async () => {
|
||||
mxEmitter.emit(MatrixEventEvent.Decrypted, { getRoomId: () => '!other:test' });
|
||||
await Promise.resolve();
|
||||
});
|
||||
|
||||
expect(result.current.timeline).toBe(before);
|
||||
});
|
||||
});
|
||||
|
||||
describe('event jump recovery', () => {
|
||||
|
||||
@@ -580,6 +580,20 @@ export function useTimelineSync({
|
||||
|
||||
useMatrixEvent(room, RoomEvent.LocalEchoUpdated, handleLocalEchoUpdated);
|
||||
|
||||
const handleDecrypted = useCallback(
|
||||
(mEvent: MatrixEvent) => {
|
||||
if (mEvent.getRoomId() !== room.roomId) return;
|
||||
setTimeline((ct) => ({ ...ct }));
|
||||
},
|
||||
[room, setTimeline]
|
||||
);
|
||||
|
||||
useMatrixEvent(
|
||||
typeof (mx as Partial<Pick<MatrixClient, 'on'>>).on === 'function' ? mx : undefined,
|
||||
MatrixEventEvent.Decrypted,
|
||||
handleDecrypted
|
||||
);
|
||||
|
||||
useLiveTimelineRefresh(
|
||||
room,
|
||||
useCallback(() => {
|
||||
|
||||
Reference in new issue
Block a user