fix: reply with album (#15424)

This commit is contained in:
yqrashawn 2023-03-22 21:04:39 +08:00 committed by GitHub
parent 554476ede9
commit f2c8f21336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 24 deletions

View File

@ -147,8 +147,9 @@
(defn build-image-messages (defn build-image-messages
[{db :db} chat-id input-text] [{db :db} chat-id input-text]
(let [images (get-in db [:chat/inputs chat-id :metadata :sending-image]) (let [images (get-in db [:chat/inputs chat-id :metadata :sending-image])
album-id (str (random-uuid))] {:keys [message-id]} (get-in db [:chat/inputs chat-id :metadata :responding-to-message])
album-id (str (random-uuid))]
(mapv (fn [[_ {:keys [resized-uri width height]}]] (mapv (fn [[_ {:keys [resized-uri width height]}]]
{:chat-id chat-id {:chat-id chat-id
:album-id album-id :album-id album-id
@ -159,7 +160,8 @@
;; TODO: message not received if text field is ;; TODO: message not received if text field is
;; nil or empty, issue: ;; nil or empty, issue:
;; https://github.com/status-im/status-mobile/issues/14754 ;; https://github.com/status-im/status-mobile/issues/14754
:text (or input-text "placeholder")}) :text (or input-text "placeholder")
:response-to message-id})
images))) images)))
(rf/defn clean-input (rf/defn clean-input

View File

@ -112,27 +112,34 @@
(defn albumize-messages (defn albumize-messages
[messages] [messages]
(get (get
(reduce (fn [{:keys [messages albums]} message] (reduce
(let [album-id (:album-id message) (fn [{:keys [messages albums]} message]
albums (cond-> albums album-id (update album-id conj message)) (let [{:keys [album-id content quoted-message]} message
messages (if album-id {:keys [response-to]} content
(conj (filterv #(not= album-id (:album-id %)) messages) albums (cond-> albums
{:album (get albums album-id) album-id (update album-id conj message))
:album-id album-id messages (if album-id
:albumize? (:albumize? message) (conj
:message-id (:message-id message) (filterv #(not= album-id (:album-id %))
:deleted? (:deleted? message) messages)
:deleted-for-me? (:deleted-for-me? message) {:album (get albums album-id)
:deleted-by (:deleted-by message) :album-id album-id
:from (:from message) :albumize? (:albumize? message)
:timestamp-str (:timestamp-str message) :message-id (:message-id message)
:content-type constants/content-type-album}) :deleted? (:deleted? message)
(conj messages message))] :deleted-for-me? (:deleted-for-me? message)
{:messages messages :deleted-by (:deleted-by message)
:albums albums})) :from (:from message)
{:messages [] :timestamp-str (:timestamp-str message)
:albums {}} :content {:response-to response-to}
messages) :quoted-message quoted-message
:content-type constants/content-type-album})
(conj messages message))]
{:messages messages
:albums albums}))
{:messages []
:albums {}}
messages)
:messages)) :messages))
(re-frame/reg-sub (re-frame/reg-sub

View File

@ -17,6 +17,8 @@
{:message-id "0x333" :album-id "abc" :albumize? true :from :xyz :timestamp-str "14:00"} {:message-id "0x333" :album-id "abc" :albumize? true :from :xyz :timestamp-str "14:00"}
{:message-id "0x222" :album-id "abc" :albumize? true :from :xyz :timestamp-str "14:00"} {:message-id "0x222" :album-id "abc" :albumize? true :from :xyz :timestamp-str "14:00"}
{:message-id "0x111" :album-id "abc" :albumize? true :from :xyz :timestamp-str "14:00"}] {:message-id "0x111" :album-id "abc" :albumize? true :from :xyz :timestamp-str "14:00"}]
:content {:response-to nil}
:quoted-message nil
:album-id "abc" :album-id "abc"
:albumize? true :albumize? true
:message-id "0x444" :message-id "0x444"