Skip to content

Commit

Permalink
fix enc msg appear as decrypting after deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbura committed Oct 19, 2023
1 parent 24491db commit 6e10cdb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app/organisms/room/RoomTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
>
<EncryptedContent mEvent={mEvent}>
{() => {
if (mEvent.isRedacted()) return <MessageDeletedContent />;
if (mEvent.getType() === MessageEvent.Sticker)
return <StickerContent mEvent={mEvent} autoPlay={mediaAutoLoad} />;
if (mEvent.getType() === MessageEvent.RoomMessage)
Expand Down
7 changes: 4 additions & 3 deletions src/app/organisms/room/message/EncryptedContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ type EncryptedContentProps = {
};

export function EncryptedContent({ mEvent, children }: EncryptedContentProps) {
const [, setDecrypted] = useState(mEvent.isBeingDecrypted());
const [, toggleDecrypted] = useState(!mEvent.isBeingDecrypted());

useEffect(() => {
const handleDecrypted: MatrixEventHandlerMap[MatrixEventEvent.Decrypted] = () =>
setDecrypted(true);
const handleDecrypted: MatrixEventHandlerMap[MatrixEventEvent.Decrypted] = () => {
toggleDecrypted((s) => !s);
};
mEvent.on(MatrixEventEvent.Decrypted, handleDecrypted);
return () => {
mEvent.removeListener(MatrixEventEvent.Decrypted, handleDecrypted);
Expand Down

0 comments on commit 6e10cdb

Please sign in to comment.