From b9bd8206c1ae87191a1c3c47af15914c9e9b67f1 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sat, 2 Mar 2019 10:59:25 -0700 Subject: [PATCH] Patch users not existing when opening settings Fixes https://github.com/vector-im/riot-web/issues/9022 --- src/components/views/settings/ProfileSettings.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/views/settings/ProfileSettings.js b/src/components/views/settings/ProfileSettings.js index 7765978931..77ffef535b 100644 --- a/src/components/views/settings/ProfileSettings.js +++ b/src/components/views/settings/ProfileSettings.js @@ -28,7 +28,15 @@ export default class ProfileSettings extends React.Component { super(); 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; if (avatarUrl) avatarUrl = client.mxcUrlToHttp(avatarUrl, 96, 96, 'crop', false); this.state = {