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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 {