[16728] Allow message editing to save link previews (#17117)

This commit is contained in:
Ibrahem Khalil 2023-08-31 10:59:49 +03:00 committed by GitHub
parent e1616ae514
commit a218499f2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 11 deletions

View File

@ -12,7 +12,8 @@
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf] [utils.re-frame :as rf]
[utils.string :as utils.string])) [utils.string :as utils.string]
[status-im.data-store.messages :as data-store-messages]))
(defn text->emoji (defn text->emoji
"Replaces emojis in a specified `text`" "Replaces emojis in a specified `text`"
@ -239,16 +240,23 @@
:text (i18n/label :t/update-to-see-sticker {"locale" "en"})}))) :text (i18n/label :t/update-to-see-sticker {"locale" "en"})})))
(rf/defn send-edited-message (rf/defn send-edited-message
[{:keys [db] :as cofx} text {:keys [message-id quoted-message chat-id]}] [{:keys [db]
:as cofx} text {:keys [message-id quoted-message chat-id]}]
(rf/merge (rf/merge
cofx cofx
{:json-rpc/call [{:method "wakuext_editMessage" {:json-rpc/call [{:method "wakuext_editMessage"
:params [{:id message-id :params [{:id message-id
:text text :text text
:content-type (if (message-content/emoji-only-content? :content-type (if (message-content/emoji-only-content?
{:text text :response-to quoted-message}) {:text text
:response-to quoted-message})
constants/content-type-emoji constants/content-type-emoji
constants/content-type-text)}] constants/content-type-text)
:linkPreviews (map #(-> %
(select-keys [:url :title :description
:thumbnail])
data-store-messages/->link-preview-rpc)
(get-in db [:chat/link-previews :unfurled]))}]
:js-response true :js-response true
:on-error #(log/error "failed to edit message " %) :on-error #(log/error "failed to edit message " %)
:on-success (fn [result] :on-success (fn [result]

View File

@ -17,10 +17,11 @@
(defn- <-link-preview-rpc (defn- <-link-preview-rpc
[preview] [preview]
(update preview (update preview :thumbnail set/rename-keys {:dataUri :data-uri}))
:thumbnail
(fn [thumbnail] (defn ->link-preview-rpc
(set/rename-keys thumbnail {:dataUri :data-uri})))) [preview]
(update preview :thumbnail set/rename-keys {:data-uri :dataUri}))
(defn <-rpc (defn <-rpc
[message] [message]

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>", "_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.166.4", "version": "v0.166.5",
"commit-sha1": "bf748de216a2061bf14afb2a410599485ee1ee7c", "commit-sha1": "22ec4ac5861cd3c907c980469a73f685b43dbda0",
"src-sha256": "0acpdc8sw6i6zpxyfzahrfbr270ldcf3jv8g4bp4kh59q2mf6bxz" "src-sha256": "0z9j9hrgab3qrc84nj12b97mkjqpas83ln5a9k6367d23jiqwmj6"
} }