Skip to content

Commit

Permalink
Use correct field in JSON RPC response
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmotta committed Oct 6, 2023
1 parent 894d360 commit c7f6a18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

(rf/defn 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]))
(let [new-previews (map data-store.messages/<-link-preview-rpc new-previews)
curr-previews (get-in db [:chat/link-previews :unfurled])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,18 @@
{:request-id request-id
:unfurled []
: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"
(let [cofx {:db {:chat/link-previews
{:request-id request-id
:unfurled [preview-github
{:url url-gitlab :loading? true}]
:cache {url-github preview-github}}}}
{db :db} (events/unfurl-parsed-urls-success cofx
request-id
[preview-gitlab])]
{db :db} (events/unfurl-parsed-urls-success
cofx
request-id
{:linkPreviews [preview-gitlab]})]
(is (= {:chat/link-previews
{:request-id request-id
:unfurled [preview-github preview-gitlab]
Expand All @@ -165,10 +166,11 @@
preview-youtube
{:url url-gitlab :loading? true}]
:cache {(:url preview-youtube) preview-youtube}}}}
{db :db} (events/unfurl-parsed-urls-success cofx
request-id
[preview-github
preview-youtube])]
{db :db} (events/unfurl-parsed-urls-success
cofx
request-id
{:linkPreviews [preview-github
preview-youtube]})]
(is (= {:chat/link-previews
{:request-id request-id
:unfurled [preview-github preview-youtube]
Expand Down

0 comments on commit c7f6a18

Please sign in to comment.