Merge pull request #2752 from matrix-org/dbkr/fix-user-not-existing

Patch users not existing when opening settings
pull/21833/head
David Baker 2019-03-05 18:49:49 +00:00 committed by GitHub
commit 52e5d15a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -28,7 +28,15 @@ export default class ProfileSettings extends React.Component {
super(); super();
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
const user = client.getUser(client.getUserId()); let user = client.getUser(client.getUserId());
if (!user) {
// XXX: We shouldn't have to do this.
// There seems to be a condition where the User object won't exist until a room
// exists on the account. To work around this, we'll just create a temporary User
// and use that.
console.warn("User object not found - creating one for ProfileSettings");
user = new User(client.getUserId());
}
let avatarUrl = user.avatarUrl; let avatarUrl = user.avatarUrl;
if (avatarUrl) avatarUrl = client.mxcUrlToHttp(avatarUrl, 96, 96, 'crop', false); if (avatarUrl) avatarUrl = client.mxcUrlToHttp(avatarUrl, 96, 96, 'crop', false);
this.state = { this.state = {