From 861c3b0d800bd2e99fd907670b953adf3099945e Mon Sep 17 00:00:00 2001 From: Mike Maxim Date: Wed, 2 Oct 2019 10:02:19 -0400 Subject: [PATCH 1/2] cancel inbox search when backgrounding the app --- shared/actions/chat2/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shared/actions/chat2/index.tsx b/shared/actions/chat2/index.tsx index 2679921f6504..1eb1df108e4c 100644 --- a/shared/actions/chat2/index.tsx +++ b/shared/actions/chat2/index.tsx @@ -1591,6 +1591,14 @@ const onToggleInboxSearch = (state: TypedState) => { return inboxSearch.nameStatus === 'initial' ? Chat2Gen.createInboxSearch({query: new HiddenString('')}) : [] } +const maybeCancelInboxSearchOnFocusChanged = (state: TypedState, action: ConfigGen.ChangedFocusPayload) => { + const inboxSearch = state.chat2.inboxSearch + if (!action.payload.appFocused && isMobile && inboxSearch) { + return Chat2Gen.createToggleInboxSearch({enabled: false}) + } + return undefined +} + function* inboxSearch(_: TypedState, action: Chat2Gen.InboxSearchPayload, logger: Saga.SagaLogger) { const {query} = action.payload const teamType = (t: RPCChatTypes.TeamType) => (t === RPCChatTypes.TeamType.complex ? 'big' : 'small') @@ -3642,6 +3650,8 @@ function* chat2Saga() { yield* Saga.chainAction2(Chat2Gen.toggleInboxSearch, onToggleInboxSearch, 'onToggleInboxSearch') yield* Saga.chainAction2(Chat2Gen.toggleInboxSearch, onMarkInboxSearchOld, 'onMarkInboxSearchOld') yield* Saga.chainAction2(Chat2Gen.inboxSearchSelect, onInboxSearchSelect, 'onInboxSearchSelect') + yield* Saga.chainAction2(ConfigGen.changedFocus, maybeCancelInboxSearchOnFocusChanged) + yield* Saga.chainGenerator( Chat2Gen.threadSearch, threadSearch, From 1154c5227cfbb805ddf4fec41c939d047af82599 Mon Sep 17 00:00:00 2001 From: Mike Maxim Date: Wed, 2 Oct 2019 10:14:16 -0400 Subject: [PATCH 2/2] feedback --- shared/actions/chat2/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/actions/chat2/index.tsx b/shared/actions/chat2/index.tsx index 1eb1df108e4c..9e855b58c144 100644 --- a/shared/actions/chat2/index.tsx +++ b/shared/actions/chat2/index.tsx @@ -1591,9 +1591,9 @@ const onToggleInboxSearch = (state: TypedState) => { return inboxSearch.nameStatus === 'initial' ? Chat2Gen.createInboxSearch({query: new HiddenString('')}) : [] } -const maybeCancelInboxSearchOnFocusChanged = (state: TypedState, action: ConfigGen.ChangedFocusPayload) => { +const maybeCancelInboxSearchOnFocusChanged = (state: TypedState, action: ConfigGen.MobileAppStatePayload) => { const inboxSearch = state.chat2.inboxSearch - if (!action.payload.appFocused && isMobile && inboxSearch) { + if (action.payload.nextAppState === 'background' && inboxSearch) { return Chat2Gen.createToggleInboxSearch({enabled: false}) } return undefined @@ -3650,7 +3650,7 @@ function* chat2Saga() { yield* Saga.chainAction2(Chat2Gen.toggleInboxSearch, onToggleInboxSearch, 'onToggleInboxSearch') yield* Saga.chainAction2(Chat2Gen.toggleInboxSearch, onMarkInboxSearchOld, 'onMarkInboxSearchOld') yield* Saga.chainAction2(Chat2Gen.inboxSearchSelect, onInboxSearchSelect, 'onInboxSearchSelect') - yield* Saga.chainAction2(ConfigGen.changedFocus, maybeCancelInboxSearchOnFocusChanged) + yield* Saga.chainAction2(ConfigGen.mobileAppState, maybeCancelInboxSearchOnFocusChanged) yield* Saga.chainGenerator( Chat2Gen.threadSearch,