Omar Basem
2022-12-16 11:33:50 +04:00
parent 7f5cbc6504
commit bc4e80352c
7 changed files with 27 additions and 13 deletions
+17 -2
View File
@@ -97,11 +97,24 @@
:params [community-id]
:on-success #(re-frame/dispatch [::mark-all-read-in-community-successful %])}]}))
(defn find-albums [messages]
(let [last-album-id (atom nil)
album-count (atom 0)]
(doseq [message messages]
(if (and (:album-id (:content (val message))) (= (:album-id (:content (val message))) @last-album-id))
(swap! album-count inc 1)
(reset! album-count 1))
(reset! last-album-id (:album-id (:content (val message))))
(if (> @album-count 3)
(println "COMPLETED AN ALBUMXXXX" @album-count)
(println "NO ALBUMXX" @album-count (:album-id (:content (val message)))))))
messages)
(fx/defn messages-loaded
"Loads more messages for current chat"
{:events [::messages-loaded]}
[{db :db} chat-id session-id {:keys [cursor messages]}]
(println "ASDF" messages)
(when-not (and (get-in db [:pagination-info chat-id :messages-initialized?])
(not= session-id
(get-in db [:pagination-info chat-id :messages-initialized?])))
@@ -109,7 +122,7 @@
;; We remove those messages that are already loaded, as we might get some duplicates
{:keys [all-messages new-messages senders contacts]}
(reduce (fn [{:keys [all-messages] :as acc}
{:keys [message-id from]
{:keys [message-id from content]
:as message}]
(cond-> acc
(not (get-in db [:chats chat-id :users from]))
@@ -125,8 +138,10 @@
:contacts {}
:new-messages []}
messages)
result (find-albums all-messages)
current-clock-value (get-in db [:pagination-info chat-id :cursor-clock-value])
clock-value (when cursor (cursor->clock-value cursor))]
;(println "ccc222" (count all-messages) (count new-messages) (count already-loaded-messages))
{:dispatch [:chat/add-senders-to-chat-users (vals senders)]
:db (-> db
(update-in [:pagination-info chat-id :cursor-clock-value]
-1
View File
@@ -127,7 +127,6 @@
(reduce reduce-js-messages
{:db db :chats #{} :senders {} :transactions #{}}
messages-js)]
(println "MMMM" response-js)
;;we want to render new messages as soon as possible
;;so we dispatch later all other events which can be handled async
{:db db
-2
View File
@@ -16,7 +16,6 @@
:clock-value :clock})))
(defn <-rpc [message]
(println "CALLEDXXXX" message)
(-> message
(clojure.set/rename-keys {:id :message-id
:whisperTimestamp :whisper-timestamp
@@ -63,7 +62,6 @@
{::json-rpc/call [{:method "wakuext_chatMessages"
:params [chat-id cursor limit]
:on-success (fn [result]
(println "RESULTXXX" result)
(on-success (update result :messages #(map <-rpc %))))
:on-error on-error}]})
@@ -32,10 +32,7 @@
{::json-rpc/call [{:method "wakuext_sendChatMessages"
:params [(mapv build-message messages)]
:js-response true
:on-success #(do
(println "MESSAGESENTXXX" %)
;(re-frame/dispatch [:transport/message-sent %])
)
:on-success #(re-frame/dispatch [:transport/message-sent %])
:on-error #(do
(log/warn "failed to send a message" %)
(js/alert (str "failed to send a message: " %)))}]})
@@ -398,8 +398,7 @@
:on-load (image-set-size dimensions)
:on-error #(swap! dimensions assoc :error true)
:source {:uri uri}}]
[rn/view {:style (style/image-message-border style-opts)}
[rn/text (str "album-id: " (:album-id content))]]]]]))))
[rn/view {:style (style/image-message-border style-opts)}]]]]))))
(defmulti ->message :content-type)
+2 -2
View File
@@ -5,12 +5,12 @@
["react-native" :refer (DevSettings LogBox)]))
;; Ignore all logs, because there are lots of temporary warnings when developing and hot reloading
;(.ignoreAllLogs LogBox)
(.ignoreAllLogs LogBox)
;; Only ignore warnings/errors that cannot be fixed for the time being.
;; When you add a warning to be ignored explain below why it is ignored and how it can be fixed.
;; When a warning is fixed make sure to remove it from here.
(.ignoreLogs ^js LogBox (clj->js ["undefined is not an object (evaluating 'e.message')"
#_(.ignoreLogs ^js LogBox (clj->js ["undefined is not an object (evaluating 'e.message')"
"Cannot read property 'message' of undefined"
"InternalError Metro has encountered an error"
"undefined Unable to resolve module `parse-svg-path`"
+6
View File
@@ -4,6 +4,7 @@
"owner": "status-im",
"repo": "status-go",
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
"version": "v0.117.1",
"commit-sha1": "8593866862175eeab6f30765e5f0b813f3b1b4db",
@@ -18,4 +19,9 @@
"commit-sha1": "bc582dea5862fb5af55b8bd1b55434ab6f8a1970",
"src-sha256": "0qdr3mmy04hga51w93l9iyf1aa7mq3mf70py46lw8770pxqj765m"
>>>>>>> 287ce6602... lint
=======
"version": "1544442347f8f86bdafce63b7c35835b1d7c9dfe",
"commit-sha1": "1544442347f8f86bdafce63b7c35835b1d7c9dfe",
"src-sha256": "15nwd0v1330dx324rlbx23xm8j91908j6phc1fiv9mk6zva4350g"
>>>>>>> 8cb5b4fc3... updates
}