forked from Ivasoft/mattermost-mobile
MM-28295 Do not remove the Channel screen from the stack tracking (#4793)
* Do not remove the Channel screen from the stack tracking * Reset stack for select server & when no teams are present
This commit is contained in:
@@ -13,8 +13,6 @@ import EphemeralStore from '@store/ephemeral_store';
|
||||
import Store from '@store/store';
|
||||
import {NavigationTypes} from '@constants';
|
||||
|
||||
const CHANNEL_SCREEN = 'Channel';
|
||||
|
||||
function getThemeFromState() {
|
||||
const state = Store.redux?.getState() || {};
|
||||
|
||||
@@ -29,8 +27,8 @@ export function resetToChannel(passProps = {}) {
|
||||
const stack = {
|
||||
children: [{
|
||||
component: {
|
||||
id: CHANNEL_SCREEN,
|
||||
name: CHANNEL_SCREEN,
|
||||
id: NavigationTypes.CHANNEL_SCREEN,
|
||||
name: NavigationTypes.CHANNEL_SCREEN,
|
||||
passProps,
|
||||
options: {
|
||||
layout: {
|
||||
@@ -88,6 +86,8 @@ export function resetToChannel(passProps = {}) {
|
||||
export function resetToSelectServer(allowOtherServers) {
|
||||
const theme = Preferences.THEMES.default;
|
||||
|
||||
EphemeralStore.clearNavigationComponents();
|
||||
|
||||
Navigation.setRoot({
|
||||
root: {
|
||||
stack: {
|
||||
@@ -150,6 +150,8 @@ export function resetToTeams(name, title, passProps = {}, options = {}) {
|
||||
},
|
||||
};
|
||||
|
||||
EphemeralStore.clearNavigationComponents();
|
||||
|
||||
Navigation.setRoot({
|
||||
root: {
|
||||
stack: {
|
||||
@@ -427,7 +429,7 @@ export function closeMainSideMenu() {
|
||||
}
|
||||
|
||||
Keyboard.dismiss();
|
||||
Navigation.mergeOptions(CHANNEL_SCREEN, {
|
||||
Navigation.mergeOptions(NavigationTypes.CHANNEL_SCREEN, {
|
||||
sideMenu: {
|
||||
left: {visible: false},
|
||||
},
|
||||
@@ -439,7 +441,7 @@ export function enableMainSideMenu(enabled, visible = true) {
|
||||
return;
|
||||
}
|
||||
|
||||
Navigation.mergeOptions(CHANNEL_SCREEN, {
|
||||
Navigation.mergeOptions(NavigationTypes.CHANNEL_SCREEN, {
|
||||
sideMenu: {
|
||||
left: {enabled, visible},
|
||||
},
|
||||
@@ -452,7 +454,7 @@ export function openSettingsSideMenu() {
|
||||
}
|
||||
|
||||
Keyboard.dismiss();
|
||||
Navigation.mergeOptions(CHANNEL_SCREEN, {
|
||||
Navigation.mergeOptions(NavigationTypes.CHANNEL_SCREEN, {
|
||||
sideMenu: {
|
||||
right: {visible: true},
|
||||
},
|
||||
@@ -465,7 +467,7 @@ export function closeSettingsSideMenu() {
|
||||
}
|
||||
|
||||
Keyboard.dismiss();
|
||||
Navigation.mergeOptions(CHANNEL_SCREEN, {
|
||||
Navigation.mergeOptions(NavigationTypes.CHANNEL_SCREEN, {
|
||||
sideMenu: {
|
||||
right: {visible: false},
|
||||
},
|
||||
|
||||
@@ -18,4 +18,6 @@ const NavigationTypes = keyMirror({
|
||||
BLUR_POST_DRAFT: null,
|
||||
});
|
||||
|
||||
NavigationTypes.CHANNEL_SCREEN = 'Channel';
|
||||
|
||||
export default NavigationTypes;
|
||||
|
||||
@@ -124,7 +124,9 @@ export function componentDidAppearListener({componentId}) {
|
||||
}
|
||||
|
||||
export function componentDidDisappearListener({componentId}) {
|
||||
EphemeralStore.removeNavigationComponentId(componentId);
|
||||
if (componentId !== NavigationTypes.CHANNEL_SCREEN) {
|
||||
EphemeralStore.removeNavigationComponentId(componentId);
|
||||
}
|
||||
|
||||
if (componentId === 'MainSidebar') {
|
||||
EventEmitter.emit(NavigationTypes.MAIN_SIDEBAR_DID_CLOSE);
|
||||
|
||||
@@ -58,7 +58,7 @@ class EphemeralStore {
|
||||
|
||||
removeNavigationComponentId = (componentId) => {
|
||||
const index = this.navigationComponentIdStack.indexOf(componentId);
|
||||
if (index > 0) {
|
||||
if (index >= 0) {
|
||||
this.navigationComponentIdStack.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user