Skip to content

Commit

Permalink
fix message does not appear after decryption complete (#2209)
Browse files Browse the repository at this point in the history
* fix message does not appear after decryption complete

* update when event get decrypted before subscribing
  • Loading branch information
ajbura authored Feb 15, 2025
1 parent 2ed3f87 commit ae88480
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/features/room/message/EncryptedContent.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { MatrixEvent, MatrixEventEvent, MatrixEventHandlerMap } from 'matrix-js-sdk';
import React, { ReactNode, useEffect, useState } from 'react';
import { MessageEvent } from '../../../../types/matrix/room';

type EncryptedContentProps = {
mEvent: MatrixEvent;
children: () => ReactNode;
};

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

useEffect(() => {
const handleDecrypted: MatrixEventHandlerMap[MatrixEventEvent.Decrypted] = () => {
toggleDecrypted((s) => !s);
toggleEncrypted(mEvent.getType() === MessageEvent.RoomMessageEncrypted);
const handleDecrypted: MatrixEventHandlerMap[MatrixEventEvent.Decrypted] = (event) => {
toggleEncrypted(event.getType() === MessageEvent.RoomMessageEncrypted);
};
mEvent.on(MatrixEventEvent.Decrypted, handleDecrypted);
return () => {
Expand Down

0 comments on commit ae88480

Please sign in to comment.