chore(url-preview): Remove old/unused code (#21603)
This commit is contained in:
parent
a60e39cfd5
commit
3787ac5b94
|
@ -4,7 +4,6 @@
|
|||
[legacy.status-im.visibility-status-updates.core :as visibility-status-updates]
|
||||
[oops.core :as oops]
|
||||
[status-im.common.pairing.events :as pairing]
|
||||
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview]
|
||||
[status-im.contexts.chat.messenger.messages.transport.events :as messages.transport]
|
||||
[status-im.contexts.communities.discover.events]
|
||||
[status-im.contexts.profile.push-notifications.local.events :as local-notifications]
|
||||
|
@ -73,10 +72,7 @@
|
|||
|
||||
"community.found"
|
||||
(let [community (transforms/js->clj event-js)]
|
||||
{:fx [[:dispatch
|
||||
[:chat.ui/cache-link-preview-data (link-preview/community-link (:id community))
|
||||
community]]
|
||||
[:dispatch [:discover-community/maybe-found-unknown-contract-community community]]]})
|
||||
{:fx [[:dispatch [:discover-community/maybe-found-unknown-contract-community community]]]})
|
||||
|
||||
"status.updates.timedout"
|
||||
(visibility-status-updates/handle-visibility-status-updates cofx (transforms/js->clj event-js))
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
(ns status-im.contexts.chat.messenger.messages.link-preview.events
|
||||
(:require [camel-snake-kebab.core :as csk]
|
||||
[utils.collection]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn community-link
|
||||
[id]
|
||||
(str "https://status.app/c#" id))
|
||||
|
||||
(rf/reg-event-fx :chat.ui/cache-link-preview-data
|
||||
(fn [{:keys [db]} [site data]]
|
||||
(let [{:profile/keys [profile]} db
|
||||
link-previews-cache (-> profile
|
||||
(get :link-previews-cache {})
|
||||
(assoc site
|
||||
(utils.collection/map-keys csk/->kebab-case-keyword
|
||||
data)))]
|
||||
{:db (assoc-in db [:profile/profile :link-previews-cache] link-previews-cache)})))
|
||||
|
||||
(rf/reg-event-fx :chat.ui/load-link-preview-data
|
||||
(fn [{{:profile/keys [profile]} :db} [link]]
|
||||
(let [{:keys [error] :as cache-data} (get-in profile [:link-previews-cache link])]
|
||||
(when (or (not cache-data) error)
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wakuext_getLinkPreviewData"
|
||||
:params [link]
|
||||
:on-success [:chat.ui/cache-link-preview-data link]
|
||||
:on-error [:chat.ui/cache-link-preview-data link
|
||||
{:error (str "Can't get preview data for " link)}]}]]]}))))
|
||||
|
||||
(rf/reg-event-fx :chat.ui/should-suggest-link-preview
|
||||
(fn [_ [enabled?]]
|
||||
{:fx [[:dispatch
|
||||
[:profile.settings/profile-update :link-preview-request-enabled (boolean enabled?)]]]}))
|
||||
|
||||
(rf/reg-event-fx :chat.ui/enable-link-previews
|
||||
(fn [{{:profile/keys [profile]} :db} [site enabled?]]
|
||||
(let [enabled-sites (if enabled?
|
||||
(conj (get profile :link-previews-enabled-sites #{}) site)
|
||||
(disj (get profile :link-previews-enabled-sites #{}) site))]
|
||||
{:fx [[:dispatch [:profile.settings/profile-update :link-previews-enabled-sites enabled-sites]]]})))
|
||||
|
||||
(rf/reg-event-fx :chat.ui/enable-all-link-previews
|
||||
(fn [_ [link-previews-whitelist enabled?]]
|
||||
(let [enabled-sites (if enabled?
|
||||
(into #{} (map :title link-previews-whitelist))
|
||||
#{})]
|
||||
{:fx [[:dispatch [:profile.settings/profile-update :link-previews-enabled-sites enabled-sites]]]})))
|
|
@ -5,7 +5,6 @@
|
|||
[oops.core :as oops]
|
||||
[schema.core :as schema]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview.events]
|
||||
status-im.contexts.communities.actions.accounts-selection.events
|
||||
status-im.contexts.communities.actions.addresses-for-permissions.events
|
||||
status-im.contexts.communities.actions.airdrop-addresses.events
|
||||
|
@ -228,10 +227,7 @@
|
|||
(when community-js
|
||||
{:db (update db :communities/fetching-communities dissoc community-id)
|
||||
:fx [[:dispatch [:communities/handle-community community-js]]
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch
|
||||
[:chat.ui/cache-link-preview-data (link-preview.events/community-link community-id)
|
||||
(data-store.communities/<-rpc community-js)]]]}))
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]]}))
|
||||
|
||||
(rf/reg-event-fx :chat.ui/community-fetched community-fetched)
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
(ns status-im.contexts.communities.events-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[legacy.status-im.data-store.communities :as data-store.communities]
|
||||
(:require
|
||||
[cljs.test :refer [deftest is testing]]
|
||||
matcher-combinators.test
|
||||
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview.events]
|
||||
[status-im.contexts.communities.events :as events]))
|
||||
|
||||
(def community-id "community-id")
|
||||
|
@ -37,7 +36,6 @@
|
|||
[:db :communities/fetching-communities community-id]))))))
|
||||
|
||||
(deftest community-fetched-test
|
||||
(with-redefs [link-preview.events/community-link (fn [id] (str "community-link+" id))]
|
||||
(testing "given a community"
|
||||
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
|
||||
arg [community-id {:id community-id}]]
|
||||
|
@ -49,10 +47,7 @@
|
|||
(testing "dispatch fxs"
|
||||
(is (match?
|
||||
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch
|
||||
[:chat.ui/cache-link-preview-data "community-link+community-id"
|
||||
(data-store.communities/<-rpc #js {"id" community-id})]]]}
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]]}
|
||||
(events/community-fetched cofx arg))))))
|
||||
(testing "given a joined community"
|
||||
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
|
||||
|
@ -60,10 +55,7 @@
|
|||
(testing "dispatch fxs, do not spectate community"
|
||||
(is (match?
|
||||
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch
|
||||
[:chat.ui/cache-link-preview-data "community-link+community-id"
|
||||
(data-store.communities/<-rpc #js {"id" community-id})]]]}
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]]}
|
||||
(events/community-fetched cofx arg))))))
|
||||
(testing "given a token-gated community"
|
||||
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
|
||||
|
@ -71,16 +63,13 @@
|
|||
(testing "dispatch fxs, do not spectate community"
|
||||
(is (match?
|
||||
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
||||
[:dispatch
|
||||
[:chat.ui/cache-link-preview-data "community-link+community-id"
|
||||
(data-store.communities/<-rpc #js {"id" community-id})]]]}
|
||||
[:dispatch [:chat.ui/spectate-community community-id]]]}
|
||||
(events/community-fetched cofx arg))))))
|
||||
(testing "given nil community"
|
||||
(testing "do nothing"
|
||||
(is (match?
|
||||
nil
|
||||
(events/community-fetched {} [community-id nil])))))))
|
||||
(events/community-fetched {} [community-id nil]))))))
|
||||
|
||||
(deftest spectate-community-test
|
||||
(testing "given a joined community"
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
status-im.contexts.chat.events
|
||||
[status-im.contexts.chat.home.add-new-contact.events]
|
||||
status-im.contexts.chat.messenger.composer.events
|
||||
status-im.contexts.chat.messenger.messages.link-preview.events
|
||||
status-im.contexts.chat.messenger.photo-selector.events
|
||||
status-im.contexts.communities.events
|
||||
status-im.contexts.communities.overview.events
|
||||
|
|
Loading…
Reference in New Issue