This commit is contained in:
Roman Volosovskyi 2016-11-30 09:42:51 +02:00
parent 4d75476be4
commit 85a48072ce
3 changed files with 18 additions and 11 deletions

View File

@ -54,7 +54,7 @@
:optimizations :none
:target :nodejs}}]}
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]
:timeout 120000}}
:timeout 240000}}
:prod {:cljsbuild {:builds [{:id "ios"
:source-paths ["src" "env/prod"]
:compiler {:output-to "index.ios.js"

View File

@ -38,7 +38,8 @@
status-im.chat.handlers.webview-bridge
status-im.chat.handlers.wallet-chat
status-im.chat.handlers.console
[taoensso.timbre :as log]))
[taoensso.timbre :as log]
[tailrecursion.priority-map :refer [priority-map-by]]))
(register-handler :set-chat-ui-props
(fn [db [_ ui-element value]]
@ -285,6 +286,10 @@
((enrich init-chat))
((after load-commands!))))
(defn compare-chats
[{timesatmp1 :timestamp} {timestamp2 :timestamp}]
(compare timestamp2 timesatmp1))
(defn initialize-chats
[{:keys [loaded-chats account-creation? chats] :as db} _]
(let [chats' (if account-creation?
@ -293,7 +298,7 @@
(map (fn [{:keys [chat-id] :as chat}]
(let [last-message (messages/get-last-message db chat-id)]
[chat-id (assoc chat :last-message last-message)])))
(into {})))
(into (priority-map-by compare-chats))))
ids (set (keys chats'))]
(-> db
@ -432,7 +437,8 @@
(fn [db [_ {:keys [chat-id clock-value] :as opts}]]
(let [chat (if (chats/exists? chat-id)
(let [{old-clock-value :clock-value :as chat} (chats/get-by-id chat-id)]
(assoc chat :clock-value (max old-clock-value clock-value)))
(assoc chat :clock-value (max old-clock-value clock-value)
:timestamp (random/timestamp)))
(prepare-chat db chat-id opts))]
(chats/save chat)
(update-in db [:chats chat-id] merge chat))))
@ -570,5 +576,6 @@
(u/side-effect!
(fn [_ [_ chat-id]]
(let [chat (-> (chats/get-by-id chat-id)
(update :clock-value inc))]
(update :clock-value inc)
(assoc :timestamp (random/timestamp)))]
(dispatch [:update-chat! chat])))))

View File

@ -77,14 +77,14 @@
[view st/chats-container
[chats-list-toolbar]
[list-view {:dataSource (to-datasource chats)
:renderRow (fn [row _ _]
(list-item [chat-list-item row]))
:renderRow (fn [[id :as row] _ _]
(list-item ^{:key id} [chat-list-item row]))
:renderFooter #(list-item [chat-shadow-item])
:renderSeparator #(list-item
(when (< %2 (- (count chats) 1))
^{:key (str "separator-" %2)}
[view st/chat-separator-wrapper
[view st/chat-separator-item]]))
(when (< %2 (- (count chats) 1))
^{:key (str "separator-" %2)}
[view st/chat-separator-wrapper
[view st/chat-separator-item]]))
:style st/list-container}]
(when (get-in platform-specific [:chats :action-button?])
[chats-action-button])