mirror of https://github.com/vector-im/riot-web
Merge pull request #5272 from matrix-org/t3chguy/fix/15255
Show server errors from saving profile settingspull/21833/head
commit
5f615bd4c9
|
@ -21,6 +21,8 @@ import Field from "../elements/Field";
|
||||||
import { getHostingLink } from '../../../utils/HostingLink';
|
import { getHostingLink } from '../../../utils/HostingLink';
|
||||||
import * as sdk from "../../../index";
|
import * as sdk from "../../../index";
|
||||||
import {OwnProfileStore} from "../../../stores/OwnProfileStore";
|
import {OwnProfileStore} from "../../../stores/OwnProfileStore";
|
||||||
|
import Modal from "../../../Modal";
|
||||||
|
import ErrorDialog from "../dialogs/ErrorDialog";
|
||||||
|
|
||||||
export default class ProfileSettings extends React.Component {
|
export default class ProfileSettings extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -75,21 +77,26 @@ export default class ProfileSettings extends React.Component {
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
const newState = {};
|
const newState = {};
|
||||||
|
|
||||||
// TODO: What do we do about errors?
|
try {
|
||||||
|
if (this.state.originalDisplayName !== this.state.displayName) {
|
||||||
|
await client.setDisplayName(this.state.displayName);
|
||||||
|
newState.originalDisplayName = this.state.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.state.originalDisplayName !== this.state.displayName) {
|
if (this.state.avatarFile) {
|
||||||
await client.setDisplayName(this.state.displayName);
|
const uri = await client.uploadContent(this.state.avatarFile);
|
||||||
newState.originalDisplayName = this.state.displayName;
|
await client.setAvatarUrl(uri);
|
||||||
}
|
newState.avatarUrl = client.mxcUrlToHttp(uri, 96, 96, 'crop', false);
|
||||||
|
newState.originalAvatarUrl = newState.avatarUrl;
|
||||||
if (this.state.avatarFile) {
|
newState.avatarFile = null;
|
||||||
const uri = await client.uploadContent(this.state.avatarFile);
|
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
|
||||||
await client.setAvatarUrl(uri);
|
await client.setAvatarUrl(""); // use empty string as Synapse 500s on undefined
|
||||||
newState.avatarUrl = client.mxcUrlToHttp(uri, 96, 96, 'crop', false);
|
}
|
||||||
newState.originalAvatarUrl = newState.avatarUrl;
|
} catch (err) {
|
||||||
newState.avatarFile = null;
|
Modal.createTrackedDialog('Failed to save profile', '', ErrorDialog, {
|
||||||
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
|
title: _t("Failed to save your profile"),
|
||||||
await client.setAvatarUrl(""); // use empty string as Synapse 500s on undefined
|
description: ((err && err.message) ? err.message : _t("The operation could not be completed")),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
|
|
|
@ -715,6 +715,8 @@
|
||||||
"Off": "Off",
|
"Off": "Off",
|
||||||
"On": "On",
|
"On": "On",
|
||||||
"Noisy": "Noisy",
|
"Noisy": "Noisy",
|
||||||
|
"Failed to save your profile": "Failed to save your profile",
|
||||||
|
"The operation could not be completed": "The operation could not be completed",
|
||||||
"<a>Upgrade</a> to your own domain": "<a>Upgrade</a> to your own domain",
|
"<a>Upgrade</a> to your own domain": "<a>Upgrade</a> to your own domain",
|
||||||
"Profile": "Profile",
|
"Profile": "Profile",
|
||||||
"Display Name": "Display Name",
|
"Display Name": "Display Name",
|
||||||
|
|
Loading…
Reference in New Issue