[FIX #2118] ui: store search-key under [:toolbar-search :show]

Chat list used to store booleans under [:toolbar-search :show] which is
different from other views and caused the issue described in #2118.
This commit is contained in:
Vitaliy Vlasov 2017-12-02 21:24:01 +02:00 committed by Andrey Shovkoplyas
parent 792e599dd4
commit 9f15a2db71
2 changed files with 10 additions and 9 deletions

View File

@ -11,8 +11,9 @@
(reg-sub :filtered-chats
:<- [:get :chats]
:<- [:get-in [:toolbar-search :text]]
(fn [[chats search-text]]
(let [unordered-chats (if search-text
:<- [:get-in [:toolbar-search :show]]
(fn [[chats search-text show-search]]
(let [unordered-chats (if (and (= show-search :chat-list) search-text)
(filter #(search-filter search-text (second %))
chats)
chats)]

View File

@ -26,12 +26,12 @@
[{:text (i18n/label :t/edit) :value #(re-frame/dispatch [:set-in [:chat-list-ui-props :edit?] true])}])
(defn android-toolbar-actions []
[(act/search #(re-frame/dispatch [:set-in [:toolbar-search :show] true]))
[(act/search #(re-frame/dispatch [:set-in [:toolbar-search :show] :chat-list]))
(act/opts android-toolbar-popup-options)])
(def ios-toolbar-popup-options
[{:text (i18n/label :t/edit-chats) :value #(re-frame/dispatch [:set-in [:chat-list-ui-props :edit?] true])}
{:text (i18n/label :t/search-chats) :value #(re-frame/dispatch [:set-in [:toolbar-search :show] true])}])
{:text (i18n/label :t/search-chats) :value #(re-frame/dispatch [:set-in [:toolbar-search :show] :chat-list])}])
(defn ios-toolbar-actions []
[(act/opts ios-toolbar-popup-options)
@ -77,13 +77,13 @@
(defview chats-list []
(letsubs [chats [:filtered-chats]
edit? [:get-in [:chat-list-ui-props :edit?]]
search? [:get-in [:toolbar-search :show]]
show-search [:get-in [:toolbar-search :show]]
tabs-hidden? [:tabs-hidden?]]
[react/view st/chats-container
(cond
edit? [toolbar-edit]
search? [toolbar-search]
:else [toolbar-view])
edit? [toolbar-edit]
(= show-search :chat-list) [toolbar-search]
:else [toolbar-view])
[react/list-view {:dataSource (to-datasource chats)
:renderRow (fn [[id :as row] _ _]
(react/list-item ^{:key id} [chat-list-item row edit?]))
@ -95,7 +95,7 @@
:renderSeparator renderers/list-separator-renderer
:style st/list-container}]
(when (and (not edit?)
(not search?)
(not= show-search :chat-list)
(get-in platform-specific [:chats :action-button?]))
[chats-action-button])
[offline-view]]))