Use doMaybeLocalRoomAction (#9038)

* Use doMaybeLocalRoomAction

* Revert unnecessary changes
This commit is contained in:
Michael Weimann 2022-07-13 07:56:36 +02:00 committed by GitHub
parent 9b8b8763f7
commit 3be20cf434
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 333 additions and 22 deletions

View file

@ -35,6 +35,7 @@ import { arrayFastClone, arraySeed } from "../../../utils/arrays";
import Field from "./Field";
import AccessibleButton from "./AccessibleButton";
import Spinner from "./Spinner";
import { doMaybeLocalRoomAction } from "../../../utils/local-room";
interface IProps extends IDialogProps {
room: Room;
@ -163,11 +164,15 @@ export default class PollCreateDialog extends ScrollableBaseModal<IProps, IState
protected submit(): void {
this.setState({ busy: true, canSubmit: false });
const pollEvent = this.createEvent();
this.matrixClient.sendEvent(
doMaybeLocalRoomAction(
this.props.room.roomId,
this.props.threadId,
pollEvent.type,
pollEvent.content,
(actualRoomId: string) => this.matrixClient.sendEvent(
actualRoomId,
this.props.threadId,
pollEvent.type,
pollEvent.content,
),
this.matrixClient,
).then(
() => this.props.onFinished(true),
).catch(e => {