Skip to content

Commit fd13357

Browse files
ibrkhalilParveshdhull
authored andcommitted
Link preview follow up bug fixes (#19359)
1 parent dcd0642 commit fd13357

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/status_im/contexts/chat/messenger/composer/link_preview/events.cljs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
(let [cache (get-in db [:chat/link-previews :cache])
3939
previews (urls->previews cache urls)
4040
new-urls (->> previews
41-
(filter :loading?)
41+
(filter (fn [{:keys [loading? status-link-preview?]}]
42+
(or loading? status-link-preview?)))
4243
(map :url))
4344
;; `request-id` is a must because we need to process only the last
4445
;; unfurling event, as well as avoid needlessly updating the app db
@@ -139,14 +140,18 @@
139140
sent."
140141
{:events [:link-preview/reset-unfurled]}
141142
[{:keys [db]}]
142-
{:db (update db :chat/link-previews dissoc :unfurled :request-id :cleared)})
143+
{:db (-> db
144+
(update :chat/link-previews dissoc :unfurled :request-id :cleared)
145+
(update :chat/status-link-previews dissoc :unfurled :request-id :cleared))})
143146

144147
(rf/defn reset-all
145148
"Reset all preview state. It is especially important to delete any cached
146149
URLs, as failing to do so results in its unbounded growth."
147150
{:events [:link-preview/reset-all]}
148151
[{:keys [db]}]
149-
{:db (dissoc db :chat/link-previews)})
152+
{:db (-> db
153+
(dissoc :chat/link-previews)
154+
(dissoc :chat/status-link-previews))})
150155

151156
(rf/defn clear-link-previews
152157
"Mark current unfurled URLs as `cleared`, meaning the user won't see previews
@@ -156,4 +161,5 @@
156161
(let [unfurled-urls (set (map :url (get-in db [:chat/link-previews :unfurled])))]
157162
{:db (-> db
158163
(update :chat/link-previews dissoc :unfurled :request-id)
164+
(update :chat/status-link-previews dissoc :unfurled :request-id)
159165
(assoc-in [:chat/link-previews :cleared] unfurled-urls))}))

0 commit comments

Comments
 (0)