Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 60e1349

Browse files
authored
MessageContextMenu: update once the message is sent (#10950)
Fixes a flaky cypress test where the "Remove" option was not appearing
1 parent 3623643 commit 60e1349

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/views/context_menus/MessageContextMenu.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
*/
1818

1919
import React, { createRef, useContext } from "react";
20-
import { EventStatus, MatrixEvent } from "matrix-js-sdk/src/models/event";
20+
import { EventStatus, MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/models/event";
2121
import { EventType, RelationType } from "matrix-js-sdk/src/@types/event";
2222
import { Relations } from "matrix-js-sdk/src/models/relations";
2323
import { RoomMemberEvent } from "matrix-js-sdk/src/models/room-member";
@@ -145,6 +145,11 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
145145

146146
public componentDidMount(): void {
147147
MatrixClientPeg.get().on(RoomMemberEvent.PowerLevel, this.checkPermissions);
148+
149+
// re-check the permissions on send progress (`maySendRedactionForEvent` only returns true for events that have
150+
// been fully sent and echoed back, and we want to ensure the "Remove" option is added once that happens.)
151+
this.props.mxEvent.on(MatrixEventEvent.Status, this.checkPermissions);
152+
148153
this.checkPermissions();
149154
}
150155

@@ -153,6 +158,7 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
153158
if (cli) {
154159
cli.removeListener(RoomMemberEvent.PowerLevel, this.checkPermissions);
155160
}
161+
this.props.mxEvent.removeListener(MatrixEventEvent.Status, this.checkPermissions);
156162
}
157163

158164
private checkPermissions = (): void => {

0 commit comments

Comments
 (0)