Allow editing polls (#7806)
This commit is contained in:
parent
fa9af44523
commit
7387f3c80a
8 changed files with 310 additions and 38 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue