diff --git a/src/addon/messages/components/contacts/contacts.ts b/src/addon/messages/components/contacts/contacts.ts index 4a23cc2d7..8df67aabb 100644 --- a/src/addon/messages/components/contacts/contacts.ts +++ b/src/addon/messages/components/contacts/contacts.ts @@ -47,6 +47,8 @@ export class AddonMessagesContactsComponent { }; searchString = ''; + protected memberInfoObserver; + constructor(sitesProvider: CoreSitesProvider, translate: TranslateService, private appProvider: CoreAppProvider, private messagesProvider: AddonMessagesProvider, private domUtils: CoreDomUtilsProvider, navParams: NavParams, private eventsProvider: CoreEventsProvider) { @@ -58,6 +60,13 @@ export class AddonMessagesContactsComponent { this.loadingMessage = this.loadingMessages; this.discussionUserId = navParams.get('discussionUserId') || false; + + // Refresh the list when a contact request is confirmed. + this.memberInfoObserver = eventsProvider.on(AddonMessagesProvider.MEMBER_INFO_CHANGED_EVENT, (data) => { + if (data.contactRequestConfirmed) { + this.refreshData(); + } + }, sitesProvider.getCurrentSiteId()); } /** @@ -217,4 +226,11 @@ export class AddonMessagesContactsComponent { }; this.eventsProvider.trigger(AddonMessagesProvider.SPLIT_VIEW_LOAD_EVENT, params, this.siteId); } + + /** + * Component destroyed. + */ + ngOnDestroy(): void { + this.memberInfoObserver && this.memberInfoObserver.off(); + } } diff --git a/src/addon/messages/pages/discussion/discussion.ts b/src/addon/messages/pages/discussion/discussion.ts index 6b94fe915..7ac5d20b7 100644 --- a/src/addon/messages/pages/discussion/discussion.ts +++ b/src/addon/messages/pages/discussion/discussion.ts @@ -223,7 +223,12 @@ export class AddonMessagesDiscussionPage implements OnDestroy { } if (this.userId) { - promises.push(this.messagesProvider.getMemberInfo(this.userId).then((member) => { + // Get the member info. Invalidate first to make sure we get the latest status. + promises.push(this.messagesProvider.invalidateMemberInfo(this.userId).catch(() => { + // Shouldn't happen. + }).then(() => { + return this.messagesProvider.getMemberInfo(this.userId); + }).then((member) => { this.otherMember = member; if (!exists && member) { this.conversationImage = member.profileimageurl;