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

Commit 4bd7ae5

Browse files
committed
Show server errors from saving profile settings
Signed-off-by: Michael Telatynski <[email protected]>
1 parent 0f2c08f commit 4bd7ae5

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

src/components/views/settings/ProfileSettings.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import Field from "../elements/Field";
2121
import {User} from "matrix-js-sdk";
2222
import { getHostingLink } from '../../../utils/HostingLink';
2323
import * as sdk from "../../../index";
24+
import Modal from "../../../Modal";
25+
import ErrorDialog from "../dialogs/ErrorDialog";
2426

2527
export default class ProfileSettings extends React.Component {
2628
constructor() {
@@ -84,21 +86,26 @@ export default class ProfileSettings extends React.Component {
8486
const client = MatrixClientPeg.get();
8587
const newState = {};
8688

87-
// TODO: What do we do about errors?
88-
89-
if (this.state.originalDisplayName !== this.state.displayName) {
90-
await client.setDisplayName(this.state.displayName);
91-
newState.originalDisplayName = this.state.displayName;
92-
}
93-
94-
if (this.state.avatarFile) {
95-
const uri = await client.uploadContent(this.state.avatarFile);
96-
await client.setAvatarUrl(uri);
97-
newState.avatarUrl = client.mxcUrlToHttp(uri, 96, 96, 'crop', false);
98-
newState.originalAvatarUrl = newState.avatarUrl;
99-
newState.avatarFile = null;
100-
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
101-
await client.setAvatarUrl(""); // use empty string as Synapse 500s on undefined
89+
try {
90+
if (this.state.originalDisplayName !== this.state.displayName) {
91+
await client.setDisplayName(this.state.displayName);
92+
newState.originalDisplayName = this.state.displayName;
93+
}
94+
95+
if (this.state.avatarFile) {
96+
const uri = await client.uploadContent(this.state.avatarFile);
97+
await client.setAvatarUrl(uri);
98+
newState.avatarUrl = client.mxcUrlToHttp(uri, 96, 96, 'crop', false);
99+
newState.originalAvatarUrl = newState.avatarUrl;
100+
newState.avatarFile = null;
101+
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
102+
await client.setAvatarUrl(""); // use empty string as Synapse 500s on undefined
103+
}
104+
} catch (err) {
105+
Modal.createTrackedDialog('Failed to save profile', '', ErrorDialog, {
106+
title: _t("Failed to save your profile"),
107+
description: ((err && err.message) ? err.message : _t("The operation could not be completed")),
108+
});
102109
}
103110

104111
this.setState(newState);

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@
714714
"Off": "Off",
715715
"On": "On",
716716
"Noisy": "Noisy",
717+
"Failed to save your profile": "Failed to save your profile",
718+
"The operation could not be completed": "The operation could not be completed",
717719
"<a>Upgrade</a> to your own domain": "<a>Upgrade</a> to your own domain",
718720
"Profile": "Profile",
719721
"Display Name": "Display Name",

0 commit comments

Comments
 (0)