Clear displayname / vatar if they're unset

pull/21833/head
David Baker 2021-03-19 11:29:14 +00:00
parent cd138bf87e
commit 4a734ef70b
1 changed files with 10 additions and 2 deletions

View File

@ -124,8 +124,16 @@ export class OwnProfileStore extends AsyncStoreWithClient<IState> {
// We specifically do not use the User object we stored for profile info as it // We specifically do not use the User object we stored for profile info as it
// could easily be wrong (such as per-room instead of global profile). // could easily be wrong (such as per-room instead of global profile).
const profileInfo = await this.matrixClient.getProfileInfo(this.matrixClient.getUserId()); const profileInfo = await this.matrixClient.getProfileInfo(this.matrixClient.getUserId());
if (profileInfo.displayname) window.localStorage.setItem(KEY_DISPLAY_NAME, profileInfo.displayname); if (profileInfo.displayname) {
if (profileInfo.avatar_url) window.localStorage.setItem(KEY_AVATAR_URL, profileInfo.avatar_url); window.localStorage.setItem(KEY_DISPLAY_NAME, profileInfo.displayname);
} else {
window.localStorage.removeItem(KEY_DISPLAY_NAME);
}
if (profileInfo.avatar_url) {
window.localStorage.setItem(KEY_AVATAR_URL, profileInfo.avatar_url);
} else {
window.localStorage.removeItem(KEY_AVATAR_URL);
}
await this.updateState({displayName: profileInfo.displayname, avatarUrl: profileInfo.avatar_url}); await this.updateState({displayName: profileInfo.displayname, avatarUrl: profileInfo.avatar_url});
}; };