fix enc msg appear as decrypting after deletion

This commit is contained in:
Ajay Bura 2023-10-19 08:13:39 +05:30
parent 24491db390
commit 6e10cdbdea
2 changed files with 5 additions and 3 deletions

View file

@ -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)

View file

@ -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);