From 948e32fbf7254ebef6ea0996f260419bc89899e7 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 13 Jul 2020 16:28:03 +1000 Subject: [PATCH] update our top left avatar on avatar changes when our primary device updates the avatar, we wait for a sync message to know about this update. Once this message comes in, it updates the avatar on the conversation, but nothing refresh the ActionPanel component. This commit makes sure we listen for changes on our conversation to trigger this refresh. --- ts/components/EditProfileDialog.tsx | 2 +- ts/components/session/ActionsPanel.tsx | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ts/components/EditProfileDialog.tsx b/ts/components/EditProfileDialog.tsx index 54abe0337..0c21c7e9c 100644 --- a/ts/components/EditProfileDialog.tsx +++ b/ts/components/EditProfileDialog.tsx @@ -337,7 +337,7 @@ export class EditProfileDialog extends React.Component { setProfileName: this.state.profileName, }, () => { - // Update settinngs in dialog complete; + // Update settings in dialog complete; // now callback to reloadactions panel avatar this.props.callback(this.state.avatar); } diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 296cd02b4..13633cacb 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -42,6 +42,16 @@ export class ActionsPanel extends React.Component { this.setState({ avatarPath: conversation.getAvatarPath(), }); + // When our primary device updates its avatar, we will need for a message sync to know about that. + // Once we get the avatar update, we need to refresh this react component. + // So we listen to changes on our profile avatar and use the updated avatarPath (done on message received). + conversation.on('change', () => { + if (conversation.changed?.profileAvatar) { + this.setState({ + avatarPath: conversation.getAvatarPath(), + }); + } + }); } ); }