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

Commit 5f615bd

Browse files
authored
Merge pull request #5272 from matrix-org/t3chguy/fix/15255
Show server errors from saving profile settings
2 parents 39c4912 + 55a18b8 commit 5f615bd

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 { getHostingLink } from '../../../utils/HostingLink';
2222
import * as sdk from "../../../index";
2323
import {OwnProfileStore} from "../../../stores/OwnProfileStore";
24+
import Modal from "../../../Modal";
25+
import ErrorDialog from "../dialogs/ErrorDialog";
2426

2527
export default class ProfileSettings extends React.Component {
2628
constructor() {
@@ -75,21 +77,26 @@ export default class ProfileSettings extends React.Component {
7577
const client = MatrixClientPeg.get();
7678
const newState = {};
7779

78-
// TODO: What do we do about errors?
79-
80-
if (this.state.originalDisplayName !== this.state.displayName) {
81-
await client.setDisplayName(this.state.displayName);
82-
newState.originalDisplayName = this.state.displayName;
83-
}
84-
85-
if (this.state.avatarFile) {
86-
const uri = await client.uploadContent(this.state.avatarFile);
87-
await client.setAvatarUrl(uri);
88-
newState.avatarUrl = client.mxcUrlToHttp(uri, 96, 96, 'crop', false);
89-
newState.originalAvatarUrl = newState.avatarUrl;
90-
newState.avatarFile = null;
91-
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
92-
await client.setAvatarUrl(""); // use empty string as Synapse 500s on undefined
80+
try {
81+
if (this.state.originalDisplayName !== this.state.displayName) {
82+
await client.setDisplayName(this.state.displayName);
83+
newState.originalDisplayName = this.state.displayName;
84+
}
85+
86+
if (this.state.avatarFile) {
87+
const uri = await client.uploadContent(this.state.avatarFile);
88+
await client.setAvatarUrl(uri);
89+
newState.avatarUrl = client.mxcUrlToHttp(uri, 96, 96, 'crop', false);
90+
newState.originalAvatarUrl = newState.avatarUrl;
91+
newState.avatarFile = null;
92+
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
93+
await client.setAvatarUrl(""); // use empty string as Synapse 500s on undefined
94+
}
95+
} catch (err) {
96+
Modal.createTrackedDialog('Failed to save profile', '', ErrorDialog, {
97+
title: _t("Failed to save your profile"),
98+
description: ((err && err.message) ? err.message : _t("The operation could not be completed")),
99+
});
93100
}
94101

95102
this.setState(newState);

src/i18n/strings/en_EN.json

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

0 commit comments

Comments
 (0)