MOBILE-2919 message: Open conversation when push clicked
parent
e97480202e
commit
6e054bf6cd
|
@ -109,11 +109,20 @@ export class AddonMessagesModule {
|
||||||
messagesProvider.invalidateDiscussionsCache(notification.site).finally(() => {
|
messagesProvider.invalidateDiscussionsCache(notification.site).finally(() => {
|
||||||
// Check if group messaging is enabled, to determine which page should be loaded.
|
// Check if group messaging is enabled, to determine which page should be loaded.
|
||||||
messagesProvider.isGroupMessagingEnabledInSite(notification.site).then((enabled) => {
|
messagesProvider.isGroupMessagingEnabledInSite(notification.site).then((enabled) => {
|
||||||
|
const pageParams: any = {};
|
||||||
let pageName = 'AddonMessagesIndexPage';
|
let pageName = 'AddonMessagesIndexPage';
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
pageName = 'AddonMessagesGroupConversationsPage';
|
pageName = 'AddonMessagesGroupConversationsPage';
|
||||||
}
|
}
|
||||||
linkHelper.goInSite(undefined, pageName, undefined, notification.site);
|
|
||||||
|
// Check if we have enough information to open the conversation.
|
||||||
|
if (notification.convid && enabled) {
|
||||||
|
pageParams.conversationId = Number(notification.convid);
|
||||||
|
} else if (notification.userfromid) {
|
||||||
|
pageParams.discussionUserId = Number(notification.userfromid);
|
||||||
|
}
|
||||||
|
|
||||||
|
linkHelper.goInSite(undefined, pageName, pageParams, notification.site);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -70,6 +70,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
protected siteId: string;
|
protected siteId: string;
|
||||||
protected currentUserId: number;
|
protected currentUserId: number;
|
||||||
protected conversationId: number;
|
protected conversationId: number;
|
||||||
|
protected discussionUserId: number;
|
||||||
protected newMessagesObserver: any;
|
protected newMessagesObserver: any;
|
||||||
protected pushObserver: any;
|
protected pushObserver: any;
|
||||||
protected appResumeSubscription: any;
|
protected appResumeSubscription: any;
|
||||||
|
@ -89,7 +90,9 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
this.loadingString = translate.instant('core.loading');
|
this.loadingString = translate.instant('core.loading');
|
||||||
this.siteId = sitesProvider.getCurrentSiteId();
|
this.siteId = sitesProvider.getCurrentSiteId();
|
||||||
this.currentUserId = sitesProvider.getCurrentSiteUserId();
|
this.currentUserId = sitesProvider.getCurrentSiteUserId();
|
||||||
|
// Conversation to load.
|
||||||
this.conversationId = navParams.get('conversationId') || false;
|
this.conversationId = navParams.get('conversationId') || false;
|
||||||
|
this.discussionUserId = !this.conversationId && (navParams.get('discussionUserId') || false);
|
||||||
|
|
||||||
// Update conversations when new message is received.
|
// Update conversations when new message is received.
|
||||||
this.newMessagesObserver = eventsProvider.on(AddonMessagesProvider.NEW_MESSAGE_EVENT, (data) => {
|
this.newMessagesObserver = eventsProvider.on(AddonMessagesProvider.NEW_MESSAGE_EVENT, (data) => {
|
||||||
|
@ -213,9 +216,9 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
* Component loaded.
|
* Component loaded.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.conversationId) {
|
if (this.conversationId || this.discussionUserId) {
|
||||||
// There is a discussion to load, open the discussion in a new state.
|
// There is a discussion to load, open the discussion in a new state.
|
||||||
this.gotoConversation(this.conversationId);
|
this.gotoConversation(this.conversationId, this.discussionUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchData().then(() => {
|
this.fetchData().then(() => {
|
||||||
|
|
Loading…
Reference in New Issue