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

Commit

Permalink
MessageContextMenu: update once the message is sent (#10950)
Browse files Browse the repository at this point in the history
Fixes a flaky cypress test where the "Remove" option was not appearing
  • Loading branch information
richvdh authored May 19, 2023
1 parent 3623643 commit 60e1349
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/views/context_menus/MessageContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
*/

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

public componentDidMount(): void {
MatrixClientPeg.get().on(RoomMemberEvent.PowerLevel, this.checkPermissions);

// re-check the permissions on send progress (`maySendRedactionForEvent` only returns true for events that have
// been fully sent and echoed back, and we want to ensure the "Remove" option is added once that happens.)
this.props.mxEvent.on(MatrixEventEvent.Status, this.checkPermissions);

this.checkPermissions();
}

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

private checkPermissions = (): void => {
Expand Down

0 comments on commit 60e1349

Please sign in to comment.