From 41caae2d2f99138cee3ddc319728558728c48ddb Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 26 Jun 2015 16:15:21 -0700 Subject: [PATCH] fix(search): Reliably clear back to previously selected Tag when you click "X" Fixes T1173 --- .../thread-list/lib/thread-list-store.coffee | 4 +++- src/flux/stores/focused-tag-store.coffee | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/internal_packages/thread-list/lib/thread-list-store.coffee b/internal_packages/thread-list/lib/thread-list-store.coffee index 3501622ab..d9ad6f7e7 100644 --- a/internal_packages/thread-list/lib/thread-list-store.coffee +++ b/internal_packages/thread-list/lib/thread-list-store.coffee @@ -85,7 +85,9 @@ ThreadListStore = Reflux.createStore # Inbound Events - _onTagChanged: -> @createView() + _onTagChanged: -> + @createView() + _onNamespaceChanged: -> namespaceId = NamespaceStore.current()?.id namespaceMatcher = (m) -> diff --git a/src/flux/stores/focused-tag-store.coffee b/src/flux/stores/focused-tag-store.coffee index d4197806c..e49384c35 100644 --- a/src/flux/stores/focused-tag-store.coffee +++ b/src/flux/stores/focused-tag-store.coffee @@ -3,6 +3,8 @@ NamespaceStore = require './namespace-store' Actions = require '../actions' Tag = require '../models/tag' +InboxTag = new Tag(id: 'inbox', name: 'inbox') + FocusedTagStore = Reflux.createStore init: -> @_resetInstanceVars() @@ -12,12 +14,12 @@ FocusedTagStore = Reflux.createStore @listenTo Actions.searchQueryCommitted, @_onSearchQueryCommitted _resetInstanceVars: -> - @_tag = new Tag(id: 'inbox', name: 'inbox') + @_tag = InboxTag # Inbound Events _onClearTag: -> - @_setTag(new Tag(id: 'inbox', name: 'inbox')) + @_setTag(InboxTag) _onFocusTag: (tag) -> return if @_tag?.id is tag?.id @@ -27,12 +29,12 @@ FocusedTagStore = Reflux.createStore @_setTag(tag) - _onSearchQueryCommitted: (_query) -> - if _query - @_oldTag = @_tag + _onSearchQueryCommitted: (query) -> + if query and @_tag + @_tagBeforeSearch = @_tag @_setTag(null) - else if @_oldTag - @_setTag(@_oldTag) + else if not query + @_setTag(@_tagBeforeSearch ? InboxTag) _setTag: (tag) -> return if @_tag?.id is tag?.id