MOBILE-4249 messages: Fix context menu items duplicated

main
Dani Palou 2023-02-17 10:24:56 +01:00
parent 77fb8f7502
commit 6b9b956474
5 changed files with 36 additions and 9 deletions

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { IonRefresher } from '@ionic/angular';
import { CoreSites } from '@services/sites';
import {
@ -29,6 +29,7 @@ import { ActivatedRoute } from '@angular/router';
import { Translate } from '@singletons';
import { CoreScreen } from '@services/screen';
import { CoreNavigator } from '@services/navigator';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
/**
* Page that displays the list of contacts.
@ -40,6 +41,8 @@ import { CoreNavigator } from '@services/navigator';
})
export class AddonMessagesContacts35Page implements OnInit, OnDestroy {
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
protected searchingMessages: string;
protected loadingMessages: string;
protected siteId: string;
@ -244,7 +247,9 @@ export class AddonMessagesContacts35Page implements OnInit, OnDestroy {
const path = CoreNavigator.getRelativePathToParent('/messages/contacts-35') + `discussion/user/${discussionUserId}`;
// @todo Check why this is failing on ngInit.
CoreNavigator.navigate(path);
CoreNavigator.navigate(path, {
reset: CoreScreen.isTablet && !!this.splitView && !this.splitView.isNested,
});
}
/**

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
import {
@ -24,6 +24,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreScreen } from '@services/screen';
import { CoreDomUtils } from '@services/utils/dom';
import { IonRefresher } from '@ionic/angular';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
/**
* Page that displays contacts and contact requests.
@ -37,6 +38,8 @@ import { IonRefresher } from '@ionic/angular';
})
export class AddonMessagesContactsPage implements OnInit, OnDestroy {
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
selected: 'confirmed' | 'requests' = 'confirmed';
requestsBadge = '';
selectedUserId?: number; // User id of the conversation opened in the split view.
@ -292,7 +295,9 @@ export class AddonMessagesContactsPage implements OnInit, OnDestroy {
this.selectedUserId = userId;
const path = CoreNavigator.getRelativePathToParent('/messages/contacts') + `discussion/user/${userId}`;
CoreNavigator.navigate(path);
CoreNavigator.navigate(path, {
reset: CoreScreen.isTablet && !!this.splitView && !this.splitView.isNested,
});
}
/**

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
import {
@ -34,6 +34,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreScreen } from '@services/screen';
import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager';
import { CorePlatform } from '@services/platform';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
/**
* Page that displays the list of discussions.
@ -45,6 +46,8 @@ import { CorePlatform } from '@services/platform';
})
export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy {
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
protected newMessagesObserver: CoreEventObserver;
protected readChangedObserver: CoreEventObserver;
protected appResumeSubscription: Subscription;
@ -264,7 +267,10 @@ export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy {
const path = CoreNavigator.getRelativePathToParent('/messages/index') + `discussion/user/${discussionUserId}`;
await CoreNavigator.navigate(path, { params });
await CoreNavigator.navigate(path, {
params,
reset: CoreScreen.isTablet && !!this.splitView && !this.splitView.isNested,
});
}
/**

View File

@ -38,6 +38,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreScreen } from '@services/screen';
import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager';
import { CorePlatform } from '@services/platform';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
/**
* Page that displays the list of conversations, including group conversations.
@ -49,6 +50,8 @@ import { CorePlatform } from '@services/platform';
})
export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
@ViewChild(IonContent) content?: IonContent;
@ViewChild('favlist') favListEl?: ElementRef;
@ViewChild('grouplist') groupListEl?: ElementRef;
@ -526,7 +529,10 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
const path = CoreNavigator.getRelativePathToParent('/messages/group-conversations') + 'discussion/' +
(conversationId ? conversationId : `user/${userId}`);
await CoreNavigator.navigate(path, { params });
await CoreNavigator.navigate(path, {
params,
reset: CoreScreen.isTablet && !!this.splitView && !this.splitView.isNested,
});
}
/**

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnDestroy } from '@angular/core';
import { Component, OnDestroy, ViewChild } from '@angular/core';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
import {
@ -25,6 +25,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreApp } from '@services/app';
import { CoreNavigator } from '@services/navigator';
import { CoreScreen } from '@services/screen';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
/**
* Page for searching users.
@ -35,6 +36,8 @@ import { CoreScreen } from '@services/screen';
})
export class AddonMessagesSearchPage implements OnDestroy {
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
disableSearch = false;
displaySearching = false;
displayResults = false;
@ -260,7 +263,9 @@ export class AddonMessagesSearchPage implements OnDestroy {
const path = CoreNavigator.getRelativePathToParent('/messages/search') + 'discussion/' +
(conversationId ? conversationId : `user/${userId}`);
CoreNavigator.navigate(path);
CoreNavigator.navigate(path, {
reset: CoreScreen.isTablet && !!this.splitView && !this.splitView.isNested,
});
}
}