Use Own Profile Store for the Profile Settings
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
0f2c08f532
commit
d3cbb51ecb
1 changed files with 5 additions and 14 deletions
|
@ -18,30 +18,21 @@ import React, {createRef} from 'react';
|
||||||
import {_t} from "../../../languageHandler";
|
import {_t} from "../../../languageHandler";
|
||||||
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
||||||
import Field from "../elements/Field";
|
import Field from "../elements/Field";
|
||||||
import {User} from "matrix-js-sdk";
|
|
||||||
import { getHostingLink } from '../../../utils/HostingLink';
|
import { getHostingLink } from '../../../utils/HostingLink';
|
||||||
import * as sdk from "../../../index";
|
import * as sdk from "../../../index";
|
||||||
|
import {OwnProfileStore} from "../../../stores/OwnProfileStore";
|
||||||
|
|
||||||
export default class ProfileSettings extends React.Component {
|
export default class ProfileSettings extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
let user = client.getUser(client.getUserId());
|
let avatarUrl = OwnProfileStore.instance.avatarMxc;
|
||||||
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);
|
if (avatarUrl) avatarUrl = client.mxcUrlToHttp(avatarUrl, 96, 96, 'crop', false);
|
||||||
this.state = {
|
this.state = {
|
||||||
userId: user.userId,
|
userId: client.getUserId(),
|
||||||
originalDisplayName: user.rawDisplayName,
|
originalDisplayName: OwnProfileStore.instance.displayName,
|
||||||
displayName: user.rawDisplayName,
|
displayName: OwnProfileStore.instance.displayName,
|
||||||
originalAvatarUrl: avatarUrl,
|
originalAvatarUrl: avatarUrl,
|
||||||
avatarUrl: avatarUrl,
|
avatarUrl: avatarUrl,
|
||||||
avatarFile: null,
|
avatarFile: null,
|
||||||
|
|
Loading…
Reference in a new issue