Skip to content

Commit 6e054bf

Browse files
committed
MOBILE-2919 message: Open conversation when push clicked
1 parent e974802 commit 6e054bf

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/addon/messages/messages.module.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,20 @@ export class AddonMessagesModule {
109109
messagesProvider.invalidateDiscussionsCache(notification.site).finally(() => {
110110
// Check if group messaging is enabled, to determine which page should be loaded.
111111
messagesProvider.isGroupMessagingEnabledInSite(notification.site).then((enabled) => {
112+
const pageParams: any = {};
112113
let pageName = 'AddonMessagesIndexPage';
113114
if (enabled) {
114115
pageName = 'AddonMessagesGroupConversationsPage';
115116
}
116-
linkHelper.goInSite(undefined, pageName, undefined, notification.site);
117+
118+
// Check if we have enough information to open the conversation.
119+
if (notification.convid && enabled) {
120+
pageParams.conversationId = Number(notification.convid);
121+
} else if (notification.userfromid) {
122+
pageParams.discussionUserId = Number(notification.userfromid);
123+
}
124+
125+
linkHelper.goInSite(undefined, pageName, pageParams, notification.site);
117126
});
118127
});
119128
});

src/addon/messages/pages/group-conversations/group-conversations.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
7070
protected siteId: string;
7171
protected currentUserId: number;
7272
protected conversationId: number;
73+
protected discussionUserId: number;
7374
protected newMessagesObserver: any;
7475
protected pushObserver: any;
7576
protected appResumeSubscription: any;
@@ -89,7 +90,9 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
8990
this.loadingString = translate.instant('core.loading');
9091
this.siteId = sitesProvider.getCurrentSiteId();
9192
this.currentUserId = sitesProvider.getCurrentSiteUserId();
93+
// Conversation to load.
9294
this.conversationId = navParams.get('conversationId') || false;
95+
this.discussionUserId = !this.conversationId && (navParams.get('discussionUserId') || false);
9396

9497
// Update conversations when new message is received.
9598
this.newMessagesObserver = eventsProvider.on(AddonMessagesProvider.NEW_MESSAGE_EVENT, (data) => {
@@ -213,9 +216,9 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
213216
* Component loaded.
214217
*/
215218
ngOnInit(): void {
216-
if (this.conversationId) {
219+
if (this.conversationId || this.discussionUserId) {
217220
// There is a discussion to load, open the discussion in a new state.
218-
this.gotoConversation(this.conversationId);
221+
this.gotoConversation(this.conversationId, this.discussionUserId);
219222
}
220223

221224
this.fetchData().then(() => {

0 commit comments

Comments
 (0)