Show an error dialog if poll creation or voting fails (#7201)

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Andy Balaam 2021-11-25 17:00:13 +00:00 committed by GitHub
parent c8765821b5
commit 965539da2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 7 deletions

View file

@ -17,6 +17,7 @@ limitations under the License.
import React from 'react';
import { _t } from '../../../languageHandler';
import { replaceableComponent } from "../../../utils/replaceableComponent";
import Modal from '../../../Modal';
import { IBodyProps } from "./IBodyProps";
import {
IPollAnswer,
@ -29,6 +30,7 @@ import StyledRadioButton from '../elements/StyledRadioButton';
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { Relations } from 'matrix-js-sdk/src/models/relations';
import { MatrixClientPeg } from '../../../MatrixClientPeg';
import ErrorDialog from '../dialogs/ErrorDialog';
// TODO: [andyb] Use extensible events library when ready
const TEXT_NODE_TYPE = "org.matrix.msc1767.text";
@ -123,6 +125,17 @@ export default class MPollBody extends React.Component<IBodyProps, IState> {
responseContent,
).catch(e => {
console.error("Failed to submit poll response event:", e);
Modal.createTrackedDialog(
'Vote not registered',
'',
ErrorDialog,
{
title: _t("Vote not registered"),
description: _t(
"Sorry, your vote was not registered. Please try again."),
},
);
});
this.setState({ selected: answerId });