Improve types for sendEvent
(#12335)
This commit is contained in:
parent
4941327c78
commit
ef2bd7ae04
26 changed files with 209 additions and 99 deletions
|
@ -25,6 +25,7 @@ import {
|
|||
M_POLL_KIND_DISCLOSED,
|
||||
M_POLL_RESPONSE,
|
||||
M_POLL_START,
|
||||
TimelineEvents,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { RelatedRelations } from "matrix-js-sdk/src/models/related-relations";
|
||||
import { PollStartEvent, PollAnswerSubevent } from "matrix-js-sdk/src/extensible_events_v1/PollStartEvent";
|
||||
|
@ -225,14 +226,20 @@ export default class MPollBody extends React.Component<IBodyProps, IState> {
|
|||
|
||||
const response = PollResponseEvent.from([answerId], this.props.mxEvent.getId()!).serialize();
|
||||
|
||||
this.context.sendEvent(this.props.mxEvent.getRoomId()!, response.type, response.content).catch((e: any) => {
|
||||
console.error("Failed to submit poll response event:", e);
|
||||
this.context
|
||||
.sendEvent(
|
||||
this.props.mxEvent.getRoomId()!,
|
||||
response.type as keyof TimelineEvents,
|
||||
response.content as TimelineEvents[keyof TimelineEvents],
|
||||
)
|
||||
.catch((e: any) => {
|
||||
console.error("Failed to submit poll response event:", e);
|
||||
|
||||
Modal.createDialog(ErrorDialog, {
|
||||
title: _t("poll|error_voting_title"),
|
||||
description: _t("poll|error_voting_description"),
|
||||
Modal.createDialog(ErrorDialog, {
|
||||
title: _t("poll|error_voting_title"),
|
||||
description: _t("poll|error_voting_description"),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
this.setState({ selected: answerId });
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||
|
||||
import React from "react";
|
||||
import classNames from "classnames";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { EventType, MatrixEvent, RelationType } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { mediaFromMxc } from "../../../customisations/Media";
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
@ -26,6 +26,7 @@ import ReactionsRowButtonTooltip from "./ReactionsRowButtonTooltip";
|
|||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
import { REACTION_SHORTCODE_KEY } from "./ReactionsRow";
|
||||
|
||||
export interface IProps {
|
||||
// The event we're displaying reactions for
|
||||
mxEvent: MatrixEvent;
|
||||
|
@ -62,10 +63,10 @@ export default class ReactionsRowButton extends React.PureComponent<IProps, ISta
|
|||
if (myReactionEvent) {
|
||||
this.context.redactEvent(mxEvent.getRoomId()!, myReactionEvent.getId()!);
|
||||
} else {
|
||||
this.context.sendEvent(mxEvent.getRoomId()!, "m.reaction", {
|
||||
this.context.sendEvent(mxEvent.getRoomId()!, EventType.Reaction, {
|
||||
"m.relates_to": {
|
||||
rel_type: "m.annotation",
|
||||
event_id: mxEvent.getId(),
|
||||
rel_type: RelationType.Annotation,
|
||||
event_id: mxEvent.getId()!,
|
||||
key: content,
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue