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

Commit

Permalink
Patch users not existing when opening settings
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Mar 2, 2019
1 parent ead73ee commit 71630af
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/views/settings/ProfileSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@ import MatrixClientPeg from "../../../MatrixClientPeg";
import Field from "../elements/Field";
import AccessibleButton from "../elements/AccessibleButton";
import classNames from 'classnames';
import {User} from "matrix-js-sdk";

export default class ProfileSettings extends React.Component {
constructor() {
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 = {
Expand Down

0 comments on commit 71630af

Please sign in to comment.