fix_: spectate communities only when opening
This commit is contained in:
parent
5bad8de886
commit
9445363467
|
@ -22,17 +22,17 @@
|
||||||
[{:keys [db]} [community-js]]
|
[{:keys [db]} [community-js]]
|
||||||
(when community-js
|
(when community-js
|
||||||
(let [{:keys [clock
|
(let [{:keys [clock
|
||||||
token-permissions-check joined id last-opened-at]
|
token-permissions-check id last-opened-at]
|
||||||
:as community} (data-store.communities/<-rpc community-js)
|
:as community} (data-store.communities/<-rpc community-js)
|
||||||
previous-last-opened-at (get-in db [:communities id :last-opened-at])]
|
previous-last-opened-at (get-in db [:communities id :last-opened-at])]
|
||||||
(when (> clock (get-in db [:communities id :clock]))
|
(when (> clock (get-in db [:communities id :clock]))
|
||||||
{:db (assoc-in db
|
{:db (assoc-in db
|
||||||
[:communities id]
|
[:communities id]
|
||||||
(assoc community :last-opened-at (max last-opened-at previous-last-opened-at)))
|
(assoc community :last-opened-at (max last-opened-at previous-last-opened-at)))
|
||||||
|
;; NOTE(cammellos): these two looks suspicious, we should not check for permissions at
|
||||||
|
;; every event signalled
|
||||||
:fx [[:dispatch
|
:fx [[:dispatch
|
||||||
[:communities/check-permissions-to-join-community-with-all-addresses id]]
|
[:communities/check-permissions-to-join-community-with-all-addresses id]]
|
||||||
(when (not joined)
|
|
||||||
[:dispatch [:chat.ui/spectate-community id]])
|
|
||||||
(when (nil? token-permissions-check)
|
(when (nil? token-permissions-check)
|
||||||
[:dispatch [:communities/check-permissions-to-join-community id]])]}))))
|
[:dispatch [:communities/check-permissions-to-join-community id]])]}))))
|
||||||
|
|
||||||
|
@ -350,7 +350,8 @@
|
||||||
(navigate-to-serialized-community community-id)
|
(navigate-to-serialized-community community-id)
|
||||||
(rf/merge
|
(rf/merge
|
||||||
cofx
|
cofx
|
||||||
{:fx [[:dispatch
|
{:fx [[:dispatch [:chat.ui/spectate-community community-id]]
|
||||||
|
[:dispatch
|
||||||
[:communities/fetch-community
|
[:communities/fetch-community
|
||||||
{:community-id community-id
|
{:community-id community-id
|
||||||
:update-last-opened-at? true}]]
|
:update-last-opened-at? true}]]
|
||||||
|
|
|
@ -178,7 +178,6 @@
|
||||||
(is (match?
|
(is (match?
|
||||||
[[:dispatch
|
[[:dispatch
|
||||||
[:communities/check-permissions-to-join-community-with-all-addresses community-id]]
|
[:communities/check-permissions-to-join-community-with-all-addresses community-id]]
|
||||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
|
||||||
[:dispatch [:communities/check-permissions-to-join-community community-id]]]
|
[:dispatch [:communities/check-permissions-to-join-community community-id]]]
|
||||||
(filter some? (:fx effects))))))
|
(filter some? (:fx effects))))))
|
||||||
|
|
||||||
|
@ -196,8 +195,7 @@
|
||||||
effects (events/handle-community {} [community])]
|
effects (events/handle-community {} [community])]
|
||||||
(is (match?
|
(is (match?
|
||||||
[[:dispatch
|
[[:dispatch
|
||||||
[:communities/check-permissions-to-join-community-with-all-addresses community-id]]
|
[:communities/check-permissions-to-join-community-with-all-addresses community-id]]]
|
||||||
[:dispatch [:chat.ui/spectate-community community-id]]]
|
|
||||||
(filter some? (:fx effects))))))
|
(filter some? (:fx effects))))))
|
||||||
(testing "given a community with lower clock"
|
(testing "given a community with lower clock"
|
||||||
(let [effects (events/handle-community {:db {:communities {community-id {:clock 3}}}} [community])]
|
(let [effects (events/handle-community {:db {:communities {community-id {:clock 3}}}} [community])]
|
||||||
|
|
Loading…
Reference in New Issue