diff --git a/android/app/src/main/java/com/statusim/GethService.java b/android/app/src/main/java/com/statusim/GethService.java index 54defce661..1473b33909 100644 --- a/android/app/src/main/java/com/statusim/GethService.java +++ b/android/app/src/main/java/com/statusim/GethService.java @@ -84,6 +84,10 @@ public class GethService extends Service { }).start(); } + public void signalEvent(String jsonEvent) { + + } + @Nullable @Override public IBinder onBind(Intent intent) { diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index 75112c96ae..e20c9fcfc1 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -48,6 +48,7 @@ (.addOrientationListener orientation #(dispatch [:set :orientation (orientation->keyword %)])) + (.lockToPortrait orientation) (.addListener device-event-emitter "keyboardDidShow" (fn [e] diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index ffe6830993..028220bb15 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -26,13 +26,12 @@ (assoc db :show-actions show-actions))) (register-handler :load-more-messages - (fn [db _] - db - ;; TODO implement - #_(let [chat-id (get-in db [:chat :current-chat-id]) - messages [:chats chat-id :messages] - new-messages (gen-messages 10)] - (update-in db messages concat new-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)))) (defn safe-trim [s] (when (string? s) @@ -336,10 +335,8 @@ (defn load-messages! ([db] (load-messages! db nil)) - ([db _] - (->> (:current-chat-id db) - messages/get-messages - (assoc db :messages)))) + ([{:keys [current-chat-id] :as db} _] + (assoc db :messages (messages/get-messages current-chat-id)))) (defn init-chat ([db] (init-chat db nil)) @@ -362,7 +359,7 @@ (map (fn [{:keys [chat-id] :as chat}] [chat-id chat])) (into {})) - ids (set (keys chats))] + ids (set (keys chats))] (-> db (assoc :chats chats) (assoc :chats-ids ids) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 7faee32d1b..fa6e3a7632 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -2,7 +2,7 @@ (def ethereum-rpc-url "http://localhost:8545") -(def server-address "http://rpc0.status.im:20000/") +(def server-address "http://api.status.im/") ;; (def server-address "http://10.0.3.2:3000/") ;; (def server-address "http://localhost:3000/") @@ -15,3 +15,5 @@ (def response-input-hiding-duration 100) (def response-suggesstion-resize-duration 100) + +(def default-number-of-messages 10) diff --git a/src/status_im/models/messages.cljs b/src/status_im/models/messages.cljs index 22ec4a564c..8bf815e520 100644 --- a/src/status_im/models/messages.cljs +++ b/src/status_im/models/messages.cljs @@ -47,6 +47,7 @@ #{c/content-type-command c/content-type-command-request} type)) +<<<<<<< HEAD (defn get-messages [chat-id] (->> (-> (r/get-by-field :msgs :chat-id chat-id) (r/sorted :timestamp :desc) @@ -63,6 +64,21 @@ (read-string preview)))) (dissoc :preview)) message))))) +======= +(defn get-messages + ([chat-id] (get-messages chat-id 0)) + ([chat-id from] + (->> (-> (r/get-by-field :msgs :chat-id chat-id) + (r/sorted :timestamp :desc) + (r/page from (+ from c/default-number-of-messages)) + (r/collection->map)) + (into '()) + reverse + (map (fn [{:keys [content-type] :as message}] + (if (command-type? content-type) + (update message :content str-to-map) + message)))))) +>>>>>>> develop (defn update-message! [{:keys [msg-id] :as msg}] (log/debug "update-message!" msg)