un-break having no displayname user settings

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2018-06-19 07:56:04 +01:00
parent 0d05250914
commit baf0d37983
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015, 2016 OpenMarket Ltd
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -23,21 +24,14 @@ import { _t } from '../../../languageHandler';
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'ChangeDisplayName', displayName: 'ChangeDisplayName',
_getDisplayName: function() { _getDisplayName: async function() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
return cli.getProfileInfo(cli.credentials.userId).then(function(result) { try {
let displayname = result.displayname; const res = await cli.getProfileInfo(cli.getUserId());
if (!displayname) { return res.displayname;
if (MatrixClientPeg.get().isGuest()) { } catch (e) {
displayname = "Guest " + MatrixClientPeg.get().getUserIdLocalpart();
} else {
displayname = MatrixClientPeg.get().getUserIdLocalpart();
}
}
return displayname;
}, function(error) {
throw new Error("Failed to fetch display name"); throw new Error("Failed to fetch display name");
}); }
}, },
_changeDisplayName: function(new_displayname) { _changeDisplayName: function(new_displayname) {