1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-28 15:22:05 +03:00

Allow editing polls (#7806)

This commit is contained in:
Andy Balaam
2022-02-17 09:13:05 +00:00
committed by GitHub
parent fa9af44523
commit 7387f3c80a
8 changed files with 310 additions and 38 deletions

View File

@ -58,8 +58,14 @@ export function isContentActionable(mxEvent: MatrixEvent): boolean {
}
export function canEditContent(mxEvent: MatrixEvent): boolean {
if (mxEvent.status === EventStatus.CANCELLED ||
mxEvent.getType() !== EventType.RoomMessage ||
const isCancellable = (
mxEvent.getType() === EventType.RoomMessage ||
M_POLL_START.matches(mxEvent.getType())
);
if (
!isCancellable ||
mxEvent.status === EventStatus.CANCELLED ||
mxEvent.isRedacted() ||
mxEvent.isRelation(RelationType.Replace) ||
mxEvent.getSender() !== MatrixClientPeg.get().getUserId()
@ -68,7 +74,14 @@ export function canEditContent(mxEvent: MatrixEvent): boolean {
}
const { msgtype, body } = mxEvent.getOriginalContent();
return (msgtype === MsgType.Text || msgtype === MsgType.Emote) && body && typeof body === 'string';
return (
M_POLL_START.matches(mxEvent.getType()) ||
(
(msgtype === MsgType.Text || msgtype === MsgType.Emote) &&
body &&
typeof body === 'string'
)
);
}
export function canEditOwnEvent(mxEvent: MatrixEvent): boolean {