parent
d59c25d55f
commit
8f7b641fa2
|
@ -64,7 +64,7 @@
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [hide? insets]}
|
[{:keys [hide? insets]}
|
||||||
{:keys [content selected-item padding-bottom-override border-radius on-close shell?
|
{:keys [content selected-item padding-bottom-override border-radius on-close shell?
|
||||||
gradient-cover? customization-color hide-handle? blur-radius]
|
gradient-cover? customization-color hide-handle? blur-radius blur-background]
|
||||||
:or {border-radius 12}}]
|
:or {border-radius 12}}]
|
||||||
(let [theme (quo.theme/use-theme)
|
(let [theme (quo.theme/use-theme)
|
||||||
{window-height :height} (rn/get-window)
|
{window-height :height} (rn/get-window)
|
||||||
|
|
|
@ -291,33 +291,23 @@
|
||||||
[{:keys [db]} [{:keys [communities]}]]
|
[{:keys [db]} [{:keys [communities]}]]
|
||||||
(when-let [community (first communities)]
|
(when-let [community (first communities)]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [:communities (:id community) :spectated] true)
|
(assoc-in [:communities (:id community) :spectated] true))
|
||||||
(assoc-in [:communities (:id community) :spectating] false))
|
|
||||||
:fx [[:dispatch [:communities/handle-community community]]
|
:fx [[:dispatch [:communities/handle-community community]]
|
||||||
[:dispatch [::mailserver/request-messages]]]}))
|
[:dispatch [::mailserver/request-messages]]]}))
|
||||||
|
|
||||||
(rf/reg-event-fx :chat.ui/spectate-community-success spectate-community-success)
|
(rf/reg-event-fx :chat.ui/spectate-community-success spectate-community-success)
|
||||||
|
|
||||||
(defn spectate-community-failed
|
|
||||||
[{:keys [db]} [community-id]]
|
|
||||||
{:db (assoc-in db [:communities community-id :spectating] false)})
|
|
||||||
|
|
||||||
(rf/reg-event-fx :chat.ui/spectate-community-failed spectate-community-failed)
|
|
||||||
|
|
||||||
(defn spectate-community
|
(defn spectate-community
|
||||||
[{:keys [db]} [community-id]]
|
[{:keys [db]} [community-id]]
|
||||||
(let [{:keys [spectated spectating joined]} (get-in db [:communities community-id])]
|
(let [{:keys [spectated joined]} (get-in db [:communities community-id])]
|
||||||
(when (and (not joined) (not spectated) (not spectating))
|
(when (and (not joined) (not spectated))
|
||||||
{:db (assoc-in db [:communities community-id :spectating] true)
|
{:json-rpc/call [{:method "wakuext_spectateCommunity"
|
||||||
:json-rpc/call [{:method "wakuext_spectateCommunity"
|
|
||||||
:params [community-id]
|
:params [community-id]
|
||||||
:on-success [:chat.ui/spectate-community-success]
|
:on-success [:chat.ui/spectate-community-success]
|
||||||
:on-error (fn [err]
|
:on-error (fn [err]
|
||||||
(log/error {:message
|
(log/error {:message
|
||||||
"Failed to spectate community"
|
"Failed to spectate community"
|
||||||
:error err})
|
:error err}))}]})))
|
||||||
(rf/dispatch [:chat.ui/spectate-community-failed
|
|
||||||
community-id]))}]})))
|
|
||||||
|
|
||||||
(schema/=> spectate-community
|
(schema/=> spectate-community
|
||||||
[:=>
|
[:=>
|
||||||
|
@ -327,7 +317,6 @@
|
||||||
[:schema [:catn [:community-id [:? :string]]]]]]
|
[:schema [:catn [:community-id [:? :string]]]]]]
|
||||||
[:maybe
|
[:maybe
|
||||||
[:map
|
[:map
|
||||||
[:db map?]
|
|
||||||
[:json-rpc/call :schema.common/rpc-call]]]])
|
[:json-rpc/call :schema.common/rpc-call]]]])
|
||||||
|
|
||||||
(rf/reg-event-fx :chat.ui/spectate-community spectate-community)
|
(rf/reg-event-fx :chat.ui/spectate-community spectate-community)
|
||||||
|
|
|
@ -95,35 +95,16 @@
|
||||||
nil
|
nil
|
||||||
(events/spectate-community {:db {:communities {community-id {:spectated true}}}}
|
(events/spectate-community {:db {:communities {community-id {:spectated true}}}}
|
||||||
[community-id])))))
|
[community-id])))))
|
||||||
(testing "given a spectating community"
|
|
||||||
(testing "do nothing"
|
|
||||||
(is (match?
|
|
||||||
nil
|
|
||||||
(events/spectate-community {:db {:communities {community-id {:spectating true}}}}
|
|
||||||
[community-id])))))
|
|
||||||
(testing "given a community"
|
(testing "given a community"
|
||||||
(testing "mark community spectating"
|
|
||||||
(is (match?
|
|
||||||
{:db {:communities {community-id {:spectating true}}}}
|
|
||||||
(events/spectate-community {:db {:communities {community-id {}}}} [community-id]))))
|
|
||||||
(testing "call spectate community rpc with correct community id"
|
(testing "call spectate community rpc with correct community id"
|
||||||
(is (match?
|
(is (match?
|
||||||
{:json-rpc/call [{:method "wakuext_spectateCommunity"
|
{:json-rpc/call [{:method "wakuext_spectateCommunity"
|
||||||
:params [community-id]}]}
|
:params [community-id]}]}
|
||||||
(events/spectate-community {:db {:communities {community-id {}}}} [community-id]))))))
|
(events/spectate-community {:db {:communities {community-id {}}}} [community-id]))))))
|
||||||
|
|
||||||
(deftest spectate-community-failed
|
(deftest spectate-community-success-test
|
||||||
(testing "mark community spectating false"
|
|
||||||
(is (match?
|
|
||||||
{:db {:communities {community-id {:spectating false}}}}
|
|
||||||
(events/spectate-community-failed {} [community-id])))))
|
|
||||||
|
|
||||||
(deftest spectate-community-success
|
|
||||||
(testing "given communities"
|
(testing "given communities"
|
||||||
(testing "mark first community spectating false"
|
|
||||||
(is (match?
|
|
||||||
{:db {:communities {community-id {:spectating false}}}}
|
|
||||||
(events/spectate-community-success {} [{:communities [{:id community-id}]}]))))
|
|
||||||
(testing "mark first community spectated true"
|
(testing "mark first community spectated true"
|
||||||
(is (match?
|
(is (match?
|
||||||
{:db {:communities {community-id {:spectated true}}}}
|
{:db {:communities {community-id {:spectated true}}}}
|
||||||
|
|
Loading…
Reference in New Issue