Skip to content

Commit 4b463e3

Browse files
committed
add a pmp rerender trigger on incoming event decryption
1 parent 920d35f commit 4b463e3

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

.changeset/fix-encrypted-pmp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fix recieved encrypted message per-message profiles not triggering rerenders.

src/app/features/room/message/Message.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
as,
1515
config,
1616
} from 'folds';
17-
1817
import {
1918
MouseEventHandler,
2019
MouseEvent,
@@ -35,6 +34,7 @@ import {
3534
Room,
3635
Relations,
3736
RoomPinnedEventsEventContent,
37+
MatrixEventEvent,
3838
} from '$types/matrix-sdk';
3939
import classNames from 'classnames';
4040
import { useAtomValue, useSetAtom } from 'jotai';
@@ -380,13 +380,15 @@ function MessageInternal(
380380
const mx = useMatrixClient();
381381
const useAuthentication = useMediaAuthentication();
382382

383-
const [editVersion, setEditVersion] = useState(0);
383+
const [contentVersion, setContentVersion] = useState(0);
384384

385385
useEffect(() => {
386-
const onReplaced = () => setEditVersion((v) => v + 1);
387-
mEvent.on('Event.replaced' as any, onReplaced);
386+
const onUpdate = () => setContentVersion((v) => v + 1);
387+
mEvent.on(MatrixEventEvent.Decrypted, onUpdate);
388+
mEvent.on(MatrixEventEvent.Replaced, onUpdate);
388389
return () => {
389-
mEvent.off('Event.replaced' as any, onReplaced);
390+
mEvent.off(MatrixEventEvent.Decrypted, onUpdate);
391+
mEvent.off(MatrixEventEvent.Replaced, onUpdate);
390392
};
391393
}, [mEvent]);
392394

@@ -411,7 +413,7 @@ function MessageInternal(
411413
| PerMessageProfileBeeperFormat
412414
| undefined;
413415
// eslint-disable-next-line react-hooks/exhaustive-deps
414-
}, [mEvent, room, editVersion]);
416+
}, [mEvent, room, contentVersion]);
415417

416418
/**
417419
* We convert the per-message profile from the Beeper format to our internal format here in the message component

0 commit comments

Comments
 (0)