show /relations error in edit history dialog

pull/21833/head
Bruno Windels 2019-07-03 12:16:58 +02:00
parent 353f5a205c
commit 344cc079c5
3 changed files with 36 additions and 4 deletions

View File

@ -28,6 +28,11 @@ limitations under the License.
flex: 1 1 auto;
}
.mx_MessageEditHistoryDialog_error {
color: $warning-color;
text-align: center;
}
.mx_MessageEditHistoryDialog_edits {
list-style-type: none;
font-size: 14px;

View File

@ -30,6 +30,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
error: null,
events: [],
nextBatch: null,
isLoading: true,
@ -45,10 +46,17 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
const opts = {from: this.state.nextBatch};
const roomId = this.props.mxEvent.getRoomId();
const eventId = this.props.mxEvent.getId();
const result = await MatrixClientPeg.get().relations(
roomId, eventId, "m.replace", "m.room.message", opts);
let result;
let resolve;
const promise = new Promise(r => resolve = r);
let reject;
const promise = new Promise((_resolve, _reject) => {resolve = _resolve; reject = _reject;});
try {
result = await MatrixClientPeg.get().relations(
roomId, eventId, "m.replace", "m.room.message", opts);
} catch (error) {
this.setState({error}, () => reject(error));
return promise;
}
this.setState({
events: this.state.events.concat(result.events),
nextBatch: result.nextBatch,
@ -82,7 +90,23 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
render() {
let content;
if (this.state.error) {
content = this.state.error;
const {error} = this.state;
if (error.errcode === "M_UNRECOGNIZED") {
content = (<p className="mx_MessageEditHistoryDialog_error">
{_t("Your homeserver doesn't seem to support this feature.")}
</p>);
} else if (error.errcode) {
// some kind of error from the homeserver
content = (<p className="mx_MessageEditHistoryDialog_error">
{_t("Something went wrong!")}
</p>);
} else {
content = (<p className="mx_MessageEditHistoryDialog_error">
{_t("Could not reach your homeserver to fetch the edit history.")}
<br />
{_t("Verify your internet connection or try again later.")}
</p>);
}
} else if (this.state.isLoading) {
const Spinner = sdk.getComponent("elements.Spinner");
content = <Spinner />;

View File

@ -1203,6 +1203,9 @@
"Manually export keys": "Manually export keys",
"You'll lose access to your encrypted messages": "You'll lose access to your encrypted messages",
"Are you sure you want to sign out?": "Are you sure you want to sign out?",
"Your homeserver doesn't seem to support this feature.": "Your homeserver doesn't seem to support this feature.",
"Could not reach your homeserver to fetch the edit history.": "Could not reach your homeserver to fetch the edit history.",
"Verify your internet connection or try again later.": "Verify your internet connection or try again later.",
"Message edits": "Message edits",
"If you run into any bugs or have feedback you'd like to share, please let us know on GitHub.": "If you run into any bugs or have feedback you'd like to share, please let us know on GitHub.",
"To help avoid duplicate issues, please <existingIssuesLink>view existing issues</existingIssuesLink> first (and add a +1) or <newIssueLink>create a new issue</newIssueLink> if you can't find it.": "To help avoid duplicate issues, please <existingIssuesLink>view existing issues</existingIssuesLink> first (and add a +1) or <newIssueLink>create a new issue</newIssueLink> if you can't find it.",