Composer - Link previews - Adjust for upcoming API breaking changes in status-go (#17573)

Adapt the JSON RPC response to the new shape returned by `wakuext_unfurlURLs` on
v0.170.0. The changes were introduced PR
https://github.com/status-im/status-go/pull/4033. There are no behavioral
changes in the API as far as mobile is concerned at the moment.
This commit is contained in:
Icaro Motta 2023-10-13 17:10:38 +00:00 committed by GitHub
parent d01c337a2c
commit 9078c3b61b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 12 deletions

View File

@ -82,7 +82,7 @@
(rf/defn unfurl-parsed-urls-success (rf/defn unfurl-parsed-urls-success
{:events [:link-preview/unfurl-parsed-urls-success]} {:events [:link-preview/unfurl-parsed-urls-success]}
[{:keys [db]} request-id new-previews] [{:keys [db]} request-id {new-previews :linkPreviews}]
(when (= request-id (get-in db [:chat/link-previews :request-id])) (when (= request-id (get-in db [:chat/link-previews :request-id]))
(let [new-previews (map data-store.messages/<-link-preview-rpc new-previews) (let [new-previews (map data-store.messages/<-link-preview-rpc new-previews)
curr-previews (get-in db [:chat/link-previews :unfurled]) curr-previews (get-in db [:chat/link-previews :unfurled])

View File

@ -139,7 +139,7 @@
{:request-id request-id {:request-id request-id
:unfurled [] :unfurled []
:cache {}}}}] :cache {}}}}]
(is (nil? (events/unfurl-parsed-urls-success cofx "banana" [preview-github]))))) (is (nil? (events/unfurl-parsed-urls-success cofx "banana" {:linkPreviews [preview-github]})))))
(testing "reconciles new previews with existing ones" (testing "reconciles new previews with existing ones"
(let [cofx {:db {:chat/link-previews (let [cofx {:db {:chat/link-previews
@ -147,9 +147,10 @@
:unfurled [preview-github :unfurled [preview-github
{:url url-gitlab :loading? true}] {:url url-gitlab :loading? true}]
:cache {url-github preview-github}}}} :cache {url-github preview-github}}}}
{db :db} (events/unfurl-parsed-urls-success cofx {db :db} (events/unfurl-parsed-urls-success
cofx
request-id request-id
[preview-gitlab])] {:linkPreviews [preview-gitlab]})]
(is (= {:chat/link-previews (is (= {:chat/link-previews
{:request-id request-id {:request-id request-id
:unfurled [preview-github preview-gitlab] :unfurled [preview-github preview-gitlab]
@ -165,10 +166,11 @@
preview-youtube preview-youtube
{:url url-gitlab :loading? true}] {:url url-gitlab :loading? true}]
:cache {(:url preview-youtube) preview-youtube}}}} :cache {(:url preview-youtube) preview-youtube}}}}
{db :db} (events/unfurl-parsed-urls-success cofx {db :db} (events/unfurl-parsed-urls-success
cofx
request-id request-id
[preview-github {:linkPreviews [preview-github
preview-youtube])] preview-youtube]})]
(is (= {:chat/link-previews (is (= {:chat/link-previews
{:request-id request-id {:request-id request-id
:unfurled [preview-github preview-youtube] :unfurled [preview-github preview-youtube]

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.168.1", "version": "v0.170.0",
"commit-sha1": "9034f0a984601d71e40d0aa846fbc5e4d01017cd", "commit-sha1": "aded258ccb68f88dc995e22f8b4e06157bb642db",
"src-sha256": "1niics10a0p3dnlfr011sqf5prrjilv6kjplnc2c51q2pw6fv35h" "src-sha256": "1wdc814yx6qam2ngrh119hm63bgjigqi4cpiawy2i0ywk47qwdbg"
} }