diff --git a/project.clj b/project.clj index f69a3d1341..8fc4d88175 100644 --- a/project.clj +++ b/project.clj @@ -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" diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index d7d1f14046..b161caae26 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -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]))))) diff --git a/src/status_im/chats_list/screen.cljs b/src/status_im/chats_list/screen.cljs index 56d00dc17a..c7a8a5b95e 100644 --- a/src/status_im/chats_list/screen.cljs +++ b/src/status_im/chats_list/screen.cljs @@ -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])