Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b9bd820

Browse files
turt2livedbkr
authored andcommitted
Patch users not existing when opening settings
Fixes element-hq/element-web#9022
1 parent 4c333f8 commit b9bd820

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/views/settings/ProfileSettings.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ export default class ProfileSettings extends React.Component {
2828
super();
2929

3030
const client = MatrixClientPeg.get();
31-
const user = client.getUser(client.getUserId());
31+
let user = client.getUser(client.getUserId());
32+
if (!user) {
33+
// XXX: We shouldn't have to do this.
34+
// There seems to be a condition where the User object won't exist until a room
35+
// exists on the account. To work around this, we'll just create a temporary User
36+
// and use that.
37+
console.warn("User object not found - creating one for ProfileSettings");
38+
user = new User(client.getUserId());
39+
}
3240
let avatarUrl = user.avatarUrl;
3341
if (avatarUrl) avatarUrl = client.mxcUrlToHttp(avatarUrl, 96, 96, 'crop', false);
3442
this.state = {

0 commit comments

Comments
 (0)