@@ -21,6 +21,8 @@ import Field from "../elements/Field";
2121import { getHostingLink } from '../../../utils/HostingLink' ;
2222import * as sdk from "../../../index" ;
2323import { OwnProfileStore } from "../../../stores/OwnProfileStore" ;
24+ import Modal from "../../../Modal" ;
25+ import ErrorDialog from "../dialogs/ErrorDialog" ;
2426
2527export 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 ) ;
0 commit comments