diff --git a/src/addon/messages/messages.module.ts b/src/addon/messages/messages.module.ts index 43b3609c6..9ea151d83 100644 --- a/src/addon/messages/messages.module.ts +++ b/src/addon/messages/messages.module.ts @@ -109,11 +109,20 @@ export class AddonMessagesModule { messagesProvider.invalidateDiscussionsCache(notification.site).finally(() => { // Check if group messaging is enabled, to determine which page should be loaded. messagesProvider.isGroupMessagingEnabledInSite(notification.site).then((enabled) => { + const pageParams: any = {}; let pageName = 'AddonMessagesIndexPage'; if (enabled) { 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); }); }); }); diff --git a/src/addon/messages/pages/group-conversations/group-conversations.ts b/src/addon/messages/pages/group-conversations/group-conversations.ts index 39be42305..6dd5f0d28 100644 --- a/src/addon/messages/pages/group-conversations/group-conversations.ts +++ b/src/addon/messages/pages/group-conversations/group-conversations.ts @@ -70,6 +70,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { protected siteId: string; protected currentUserId: number; protected conversationId: number; + protected discussionUserId: number; protected newMessagesObserver: any; protected pushObserver: any; protected appResumeSubscription: any; @@ -89,7 +90,9 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { this.loadingString = translate.instant('core.loading'); this.siteId = sitesProvider.getCurrentSiteId(); this.currentUserId = sitesProvider.getCurrentSiteUserId(); + // Conversation to load. this.conversationId = navParams.get('conversationId') || false; + this.discussionUserId = !this.conversationId && (navParams.get('discussionUserId') || false); // Update conversations when new message is received. this.newMessagesObserver = eventsProvider.on(AddonMessagesProvider.NEW_MESSAGE_EVENT, (data) => { @@ -213,9 +216,9 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { * Component loaded. */ ngOnInit(): void { - if (this.conversationId) { + if (this.conversationId || this.discussionUserId) { // 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(() => {