MOBILE-2630 messages: Refresh contacts when request accepted

main
Dani Palou 2019-01-03 09:49:23 +01:00
parent 01fd05a168
commit 4385952fc2
2 changed files with 22 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -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;