Skip to content

Commit

Permalink
Remove old link preview code
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmotta committed Nov 7, 2024
1 parent ca22b67 commit 3f3827a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 106 deletions.
6 changes: 1 addition & 5 deletions src/status_im/common/signals/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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))
Expand Down

This file was deleted.

6 changes: 1 addition & 5 deletions src/status_im/contexts/communities/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
83 changes: 36 additions & 47 deletions src/status_im/contexts/communities/events_test.cljs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(ns status-im.contexts.communities.events-test
(:require [cljs.test :refer [deftest is testing]]
[legacy.status-im.data-store.communities :as data-store.communities]
matcher-combinators.test
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview.events]
[status-im.contexts.communities.events :as events]))
(:require
[cljs.test :refer [deftest is testing]]
matcher-combinators.test
[status-im.contexts.communities.events :as events]))

(def community-id "community-id")

Expand Down Expand Up @@ -37,50 +36,40 @@
[: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}]]
(testing "remove community id from fetching indicator in db"
(is (match?
nil
(get-in (events/community-fetched cofx arg)
[:db :communities/fetching-communities community-id]))))
(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})]]]}
(events/community-fetched cofx arg))))))
(testing "given a joined community"
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
arg [community-id {:id community-id :joined true}]]
(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})]]]}
(events/community-fetched cofx arg))))))
(testing "given a token-gated community"
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
arg [community-id {:id community-id :tokenPermissions [1]}]]
(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})]]]}
(events/community-fetched cofx arg))))))
(testing "given nil community"
(testing "do nothing"
(testing "given a community"
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
arg [community-id {:id community-id}]]
(testing "remove community id from fetching indicator in db"
(is (match?
nil
(events/community-fetched {} [community-id nil])))))))
(get-in (events/community-fetched cofx arg)
[:db :communities/fetching-communities community-id]))))
(testing "dispatch fxs"
(is (match?
{:fx [[:dispatch [:communities/handle-community {: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}}}
arg [community-id {:id community-id :joined true}]]
(testing "dispatch fxs, do not spectate community"
(is (match?
{:fx [[:dispatch [:communities/handle-community {: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}}}
arg [community-id {:id community-id :tokenPermissions [1]}]]
(testing "dispatch fxs, do not spectate community"
(is (match?
{:fx [[:dispatch [:communities/handle-community {: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]))))))

(deftest spectate-community-test
(testing "given a joined community"
Expand Down
1 change: 0 additions & 1 deletion src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3f3827a

Please sign in to comment.