From 1a35250811306c0e02a5dbde6de9830f90067c90 Mon Sep 17 00:00:00 2001 From: Anurag Shivarathri Date: Thu, 7 Oct 2021 03:37:20 +0530 Subject: [PATCH] Excluding follow button in the header from being added to the stack (#5723) --- app/mattermost.js | 4 +++- app/mattermost.test.js | 6 ++++++ app/screens/thread/thread_base.js | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/mattermost.js b/app/mattermost.js index 84bcc05de..54e0b99e9 100644 --- a/app/mattermost.js +++ b/app/mattermost.js @@ -105,7 +105,9 @@ Navigation.events().registerAppLaunchedListener(() => { }); export function componentDidAppearListener({componentId}) { - EphemeralStore.addNavigationComponentId(componentId); + if (componentId.indexOf('!screen') !== 0) { + EphemeralStore.addNavigationComponentId(componentId); + } switch (componentId) { case 'MainSidebar': diff --git a/app/mattermost.test.js b/app/mattermost.test.js index f03fa2344..abd366737 100644 --- a/app/mattermost.test.js +++ b/app/mattermost.test.js @@ -52,6 +52,12 @@ describe('componentDidAppearListener', () => { expect(EventEmitter.emit).toHaveBeenCalledTimes(1); expect(EventEmitter.emit).toHaveBeenCalledWith(NavigationTypes.BLUR_POST_DRAFT); }); + + it('should not add componentIds starting with "!screen" to the store as they are not screens', () => { + const componentId = '!screen'; + componentDidAppearListener({componentId}); + expect(EphemeralStore.addNavigationComponentId).not.toHaveBeenCalledWith(componentId); + }); }); describe('componentDidDisappearListener', () => { diff --git a/app/screens/thread/thread_base.js b/app/screens/thread/thread_base.js index b683e6bb2..7f63d5bba 100644 --- a/app/screens/thread/thread_base.js +++ b/app/screens/thread/thread_base.js @@ -57,7 +57,8 @@ export default class ThreadBase extends PureComponent { if (props.collapsedThreadsEnabled) { // Without unique id, it breaks navigation from permalink view. - this.threadFollowId = Math.floor(Math.random() * 0x10000000000).toString(16); + // Adding prefix "!screen" to exclude it from being added to stack + this.threadFollowId = '!screen-' + Math.floor(Math.random() * 0x10000000000).toString(16); let titleText; if (channelType === General.DM_CHANNEL) {