Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cancel inbox search when backgrounding the app #20067

Merged
merged 2 commits into from Oct 2, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions shared/actions/chat2/index.tsx
Expand Up @@ -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) {
mmaxim marked this conversation as resolved.
Show resolved Hide resolved
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')
Expand Down Expand Up @@ -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.ThreadSearchPayload>(
Chat2Gen.threadSearch,
threadSearch,
Expand Down