MOBILE-2620 messages: Update blocked status of conversations
parent
dca25d2e01
commit
d9a22a43b5
|
@ -68,6 +68,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
protected openConversationObserver: any;
|
protected openConversationObserver: any;
|
||||||
protected updateConversationListObserver: any;
|
protected updateConversationListObserver: any;
|
||||||
protected contactRequestsCountObserver: any;
|
protected contactRequestsCountObserver: any;
|
||||||
|
protected memberInfoObserver: any;
|
||||||
|
|
||||||
constructor(private eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider, translate: TranslateService,
|
constructor(private eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider, translate: TranslateService,
|
||||||
private messagesProvider: AddonMessagesProvider, private domUtils: CoreDomUtilsProvider, navParams: NavParams,
|
private messagesProvider: AddonMessagesProvider, private domUtils: CoreDomUtilsProvider, navParams: NavParams,
|
||||||
|
@ -164,6 +165,27 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
this.contactRequestsCountObserver = eventsProvider.on(AddonMessagesProvider.CONTACT_REQUESTS_COUNT_EVENT, (data) => {
|
this.contactRequestsCountObserver = eventsProvider.on(AddonMessagesProvider.CONTACT_REQUESTS_COUNT_EVENT, (data) => {
|
||||||
this.contactRequestsCount = data.count;
|
this.contactRequestsCount = data.count;
|
||||||
}, this.siteId);
|
}, this.siteId);
|
||||||
|
|
||||||
|
// Update block status of a user.
|
||||||
|
this.memberInfoObserver = eventsProvider.on(AddonMessagesProvider.MEMBER_INFO_CHANGED_EVENT, (data) => {
|
||||||
|
if (!data.userBlocked && !data.userUnblocked) {
|
||||||
|
// The block status has not changed, ignore.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateConversations = (conversations: any[]): void => {
|
||||||
|
if (!conversations || conversations.length <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const conversation = conversations.find((conv) => conv.userid == data.userId);
|
||||||
|
if (conversation) {
|
||||||
|
conversation.isblocked = data.userBlocked;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateConversations(this.individual.conversations);
|
||||||
|
updateConversations(this.favourites.conversations);
|
||||||
|
}, this.siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -533,5 +555,6 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
this.openConversationObserver && this.openConversationObserver.off();
|
this.openConversationObserver && this.openConversationObserver.off();
|
||||||
this.updateConversationListObserver && this.updateConversationListObserver.off();
|
this.updateConversationListObserver && this.updateConversationListObserver.off();
|
||||||
this.contactRequestsCountObserver && this.contactRequestsCountObserver.off();
|
this.contactRequestsCountObserver && this.contactRequestsCountObserver.off();
|
||||||
|
this.memberInfoObserver && this.memberInfoObserver.off();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue