parent
2280fd7124
commit
b746bcef4f
|
@ -8,7 +8,8 @@
|
|||
[status-im.models.messages :as messages]
|
||||
[status-im.constants :refer [text-content-type
|
||||
content-type-command
|
||||
content-type-command-request]]
|
||||
content-type-command-request
|
||||
default-number-of-messages]]
|
||||
[status-im.utils.random :as random]
|
||||
[status-im.chat.sign-up :as sign-up-service]
|
||||
[status-im.models.chats :as chats]
|
||||
|
@ -28,12 +29,17 @@
|
|||
(assoc db :show-actions show-actions)))
|
||||
|
||||
(register-handler :load-more-messages
|
||||
debug
|
||||
(fn [{:keys [current-chat-id] :as db} _]
|
||||
(let [messages-path [:chats current-chat-id :messages]
|
||||
messages (get-in db messages-path)
|
||||
new-messages (messages/get-messages current-chat-id (count messages))]
|
||||
(update-in db messages-path concat new-messages))))
|
||||
(let [all-loaded? (get-in db [:chats current-chat-id :all-loaded?])]
|
||||
(if all-loaded?
|
||||
db
|
||||
(let [messages-path [:chats current-chat-id :messages]
|
||||
messages (get-in db messages-path)
|
||||
new-messages (messages/get-messages current-chat-id (count messages))
|
||||
all-loaded? (> default-number-of-messages (count new-messages))]
|
||||
(-> db
|
||||
(update-in messages-path concat new-messages)
|
||||
(assoc-in [:chats current-chat-id :all-loaded?] all-loaded?)))))))
|
||||
|
||||
(defn safe-trim [s]
|
||||
(when (string? s)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns status-im.commands.handlers.loading
|
||||
(:require-macros [status-im.utils.slurp :refer [slurp]])
|
||||
(:require [re-frame.core :refer [register-handler after dispatch subscribe
|
||||
trim-v debug]]
|
||||
(:require [re-frame.core :refer [after dispatch subscribe trim-v debug]]
|
||||
[status-im.utils.handlers :as u]
|
||||
[status-im.utils.utils :refer [http-get toast]]
|
||||
[clojure.string :as s]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[clojure.walk :as w]
|
||||
[status-im.components.react :refer [text scroll-view view
|
||||
image touchable-highlight]]
|
||||
[re-frame.core :refer [register-handler dispatch trim-v debug]]
|
||||
[re-frame.core :refer [dispatch trim-v debug]]
|
||||
[status-im.utils.handlers :refer [register-handler]]))
|
||||
|
||||
(defn json->clj [json]
|
||||
|
|
|
@ -16,4 +16,4 @@
|
|||
(def response-input-hiding-duration 100)
|
||||
(def response-suggesstion-resize-duration 100)
|
||||
|
||||
(def default-number-of-messages 20)
|
||||
(def default-number-of-messages 5)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
(ns status-im.contacts.handlers
|
||||
(:require [re-frame.core :refer [register-handler after dispatch]]
|
||||
(:require [re-frame.core :refer [after dispatch]]
|
||||
[status-im.utils.handlers :refer [register-handler]]
|
||||
[status-im.models.contacts :as contacts]
|
||||
[status-im.utils.crypt :refer [encrypt]]
|
||||
[clojure.string :as s]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
(ns status-im.discovery.handlers
|
||||
(:require [re-frame.core :refer [register-handler after dispatch enrich]]
|
||||
(:require [re-frame.core :refer [after dispatch enrich]]
|
||||
[status-im.utils.handlers :refer [register-handler]]
|
||||
[status-im.protocol.api :as api]
|
||||
[status-im.navigation.handlers :as nav]
|
||||
[status-im.discovery.model :as discoveries]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.group-settings.handlers
|
||||
(:require [re-frame.core :refer [register-handler debug dispatch after
|
||||
enrich]]
|
||||
(:require [re-frame.core :refer [debug dispatch after enrich]]
|
||||
[status-im.utils.handlers :refer [register-handler]]
|
||||
[status-im.persistence.realm :as r]
|
||||
[status-im.chat.handlers :refer [delete-messages!]]
|
||||
[status-im.protocol.api :as api]
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
(r/collection->map))
|
||||
(into '())
|
||||
reverse
|
||||
(map (fn [{:keys [content-type] :as message}]
|
||||
(keep (fn [{:keys [content-type] :as message}]
|
||||
(if (command-type? content-type)
|
||||
(update message :content str-to-map)
|
||||
message))))))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
(ns status-im.navigation.handlers
|
||||
(:require [re-frame.core :refer [register-handler dispatch debug enrich after]]))
|
||||
(:require [re-frame.core :refer [dispatch debug enrich after]]
|
||||
[status-im.utils.handlers :refer [register-handler]]))
|
||||
|
||||
(defn push-view [db view-id]
|
||||
(-> db
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns status-im.new-group.handlers
|
||||
(:require [status-im.protocol.api :as api]
|
||||
[re-frame.core :refer [register-handler after dispatch debug enrich]]
|
||||
[re-frame.core :refer [after dispatch debug enrich]]
|
||||
[status-im.utils.handlers :refer [register-handler]]
|
||||
[status-im.components.styles :refer [default-chat-color]]
|
||||
[status-im.models.chats :as chats]
|
||||
[clojure.string :as s]))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns status-im.participants.handlers
|
||||
(:require [status-im.navigation.handlers :as nav]
|
||||
[re-frame.core :refer [register-handler debug]]))
|
||||
[re-frame.core :refer [debug]]
|
||||
[status-im.utils.handlers :refer [register-handler]]))
|
||||
|
||||
(defmethod nav/preload-data! :add-participants
|
||||
[db _]
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
(:require [status-im.utils.handlers :as u]
|
||||
[status-im.utils.logging :as log]
|
||||
[status-im.protocol.api :as api]
|
||||
[re-frame.core :refer [register-handler dispatch debug]]
|
||||
[re-frame.core :refer [dispatch debug]]
|
||||
[status-im.utils.handlers :refer [register-handler]]
|
||||
[status-im.models.contacts :as contacts]
|
||||
[status-im.protocol.api :refer [init-protocol]]
|
||||
[status-im.protocol.protocol-handler :refer [make-handler]]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
(ns status-im.qr-scanner.handlers
|
||||
(:require [re-frame.core :refer [register-handler after dispatch debug enrich]]
|
||||
(:require [re-frame.core :refer [after dispatch debug enrich]]
|
||||
[status-im.utils.handlers :refer [register-handler]]
|
||||
[status-im.navigation.handlers :as nav]
|
||||
[status-im.utils.handlers :as u]))
|
||||
|
||||
|
|
Loading…
Reference in New Issue