Move editEvent()
to EventUtils
(#7836)
This commit is contained in:
parent
34567b9aab
commit
fe7f1688dd
5 changed files with 71 additions and 63 deletions
|
@ -23,8 +23,12 @@ import { M_POLL_START } from "matrix-events-sdk";
|
|||
|
||||
import { MatrixClientPeg } from '../MatrixClientPeg';
|
||||
import shouldHideEvent from "../shouldHideEvent";
|
||||
import { getHandlerTile, haveTileForEvent } from "../components/views/rooms/EventTile";
|
||||
import { getHandlerTile, GetRelationsForEvent, haveTileForEvent } from "../components/views/rooms/EventTile";
|
||||
import SettingsStore from "../settings/SettingsStore";
|
||||
import defaultDispatcher from "../dispatcher/dispatcher";
|
||||
import { TimelineRenderingType } from "../contexts/RoomContext";
|
||||
import { launchPollEditor } from "../components/views/messages/MPollBody";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
|
||||
/**
|
||||
* Returns whether an event should allow actions like reply, reactions, edit, etc.
|
||||
|
@ -312,3 +316,21 @@ export async function fetchInitialEvent(
|
|||
|
||||
return initialEvent;
|
||||
}
|
||||
|
||||
export function editEvent(
|
||||
mxEvent: MatrixEvent,
|
||||
timelineRenderingType: TimelineRenderingType,
|
||||
getRelationsForEvent?: GetRelationsForEvent,
|
||||
): void {
|
||||
if (!canEditContent(mxEvent)) return;
|
||||
|
||||
if (M_POLL_START.matches(mxEvent.getType())) {
|
||||
launchPollEditor(mxEvent, getRelationsForEvent);
|
||||
} else {
|
||||
defaultDispatcher.dispatch({
|
||||
action: Action.EditEvent,
|
||||
event: mxEvent,
|
||||
timelineRenderingType: timelineRenderingType,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue