Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

show /relations error in edit history dialog #3174

Merged
merged 3 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions res/css/views/dialogs/_MessageEditHistoryDialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 32 additions & 4 deletions src/components/views/dialogs/MessageEditHistoryDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
error: null,
events: [],
nextBatch: null,
isLoading: true,
Expand All @@ -45,10 +46,21 @@ 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;});
bwindels marked this conversation as resolved.
Show resolved Hide resolved
try {
result = await MatrixClientPeg.get().relations(
roomId, eventId, "m.replace", "m.room.message", opts);
} catch (error) {
// log if the server returned an error
if (error.errcode) {
console.error("fetching /relations failed with error", error);
}
this.setState({error}, () => reject(error));
return promise;
}
this.setState({
events: this.state.events.concat(result.events),
nextBatch: result.nextBatch,
Expand Down Expand Up @@ -82,7 +94,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>);
bwindels marked this conversation as resolved.
Show resolved Hide resolved
} else {
content = (<p className="mx_MessageEditHistoryDialog_error">
{_t("Cannot reach homeserver")}
<br />
{_t("Ensure you have a stable internet connection, or get in touch with the server admin")}
</p>);
}
} else if (this.state.isLoading) {
const Spinner = sdk.getComponent("elements.Spinner");
content = <Spinner />;
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@
"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.",
"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.",
Expand Down