Remove cljs-priority-map
cljs-priority-map provides a special purpose data structure that needlessly complicated things and doesn't appear to provide much value for what it gives us. Instead, keep :chats an ordinary map and sort vector on final subscription, as our ListView destructures data-source items correctly. This means we can upgrade Clojurescript.
This commit is contained in:
parent
efd5a4c841
commit
cdc996caa2
|
@ -3,12 +3,11 @@
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||||
:dependencies [[org.clojure/clojure "1.9.0-alpha17"]
|
:dependencies [[org.clojure/clojure "1.9.0-alpha17"]
|
||||||
[org.clojure/clojurescript "1.9.671"] ;; Can't update to more recent releases waiting for https://github.com/tailrecursion/cljs-priority-map/issues/10
|
[org.clojure/clojurescript "1.9.671"] ;; TODO: Update, cljs-priority-map blocker issue is gone.
|
||||||
[org.clojure/core.async "0.3.443"]
|
[org.clojure/core.async "0.3.443"]
|
||||||
[reagent "0.6.0" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]]
|
[reagent "0.6.0" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]]
|
||||||
[re-frame "0.10.1"]
|
[re-frame "0.10.1"]
|
||||||
[com.andrewmcveigh/cljs-time "0.5.0"]
|
[com.andrewmcveigh/cljs-time "0.5.0"]
|
||||||
[tailrecursion/cljs-priority-map "1.2.0"]
|
|
||||||
[com.taoensso/timbre "4.10.0"]
|
[com.taoensso/timbre "4.10.0"]
|
||||||
[hickory "0.7.1"]]
|
[hickory "0.7.1"]]
|
||||||
:plugins [[lein-cljsbuild "1.1.7"]
|
:plugins [[lein-cljsbuild "1.1.7"]
|
||||||
|
|
|
@ -39,8 +39,7 @@
|
||||||
[cljs.core.async :as a]
|
[cljs.core.async :as a]
|
||||||
status-im.chat.handlers.webview-bridge
|
status-im.chat.handlers.webview-bridge
|
||||||
status-im.chat.handlers.console
|
status-im.chat.handlers.console
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]))
|
||||||
[tailrecursion.priority-map :refer [priority-map-by]]))
|
|
||||||
|
|
||||||
(register-handler :set-layout-height
|
(register-handler :set-layout-height
|
||||||
(fn [db [_ height]]
|
(fn [db [_ height]]
|
||||||
|
@ -208,10 +207,6 @@
|
||||||
init-chat
|
init-chat
|
||||||
load-commands!))
|
load-commands!))
|
||||||
|
|
||||||
(defn compare-chats
|
|
||||||
[{timesatmp1 :timestamp} {timestamp2 :timestamp}]
|
|
||||||
(compare timestamp2 timesatmp1))
|
|
||||||
|
|
||||||
(defn initialize-chats
|
(defn initialize-chats
|
||||||
[{:keys [loaded-chats chats] :accounts/keys [account-creation?] :as db} _]
|
[{:keys [loaded-chats chats] :accounts/keys [account-creation?] :as db} _]
|
||||||
(let [chats' (if account-creation?
|
(let [chats' (if account-creation?
|
||||||
|
@ -220,7 +215,7 @@
|
||||||
(map (fn [{:keys [chat-id] :as chat}]
|
(map (fn [{:keys [chat-id] :as chat}]
|
||||||
(let [last-message (messages/get-last-message chat-id)]
|
(let [last-message (messages/get-last-message chat-id)]
|
||||||
[chat-id (assoc chat :last-message last-message)])))
|
[chat-id (assoc chat :last-message last-message)])))
|
||||||
(into (priority-map-by compare-chats))))]
|
(into {})))]
|
||||||
|
|
||||||
(-> db
|
(-> db
|
||||||
(assoc :chats chats')
|
(assoc :chats chats')
|
||||||
|
@ -248,7 +243,7 @@
|
||||||
prev-chat (get chats chat-id)
|
prev-chat (get chats chat-id)
|
||||||
new-chat (assoc chat :last-message last-message)]
|
new-chat (assoc chat :last-message last-message)]
|
||||||
[chat-id (merge prev-chat new-chat)])))
|
[chat-id (merge prev-chat new-chat)])))
|
||||||
(into (priority-map-by compare-chats)))]
|
(into {}))]
|
||||||
(-> (assoc db :chats chats')
|
(-> (assoc db :chats chats')
|
||||||
(init-console-chat true)))))
|
(init-console-chat true)))))
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
:<- [:get :chats]
|
:<- [:get :chats]
|
||||||
:<- [:get-in [:toolbar-search :text]]
|
:<- [:get-in [:toolbar-search :text]]
|
||||||
(fn [[chats search-text]]
|
(fn [[chats search-text]]
|
||||||
(if search-text
|
(let [unordered-chats (if search-text
|
||||||
(filter #(search-filter search-text (second %)) chats)
|
(filter #(search-filter search-text (second %))
|
||||||
chats)))
|
chats)
|
||||||
|
chats)]
|
||||||
|
(sort-by #(-> % second :timestamp) > unordered-chats))))
|
||||||
|
|
Loading…
Reference in New Issue