cache processed description
This commit is contained in:
parent
4fa9a27cd9
commit
e002fab376
|
@ -4,13 +4,6 @@
|
||||||
[clojure.walk :as walk]
|
[clojure.walk :as walk]
|
||||||
[status-im.constants :as constants]))
|
[status-im.constants :as constants]))
|
||||||
|
|
||||||
(defn rpc->channel-permissions
|
|
||||||
[rpc-channels-permissions]
|
|
||||||
(update-vals rpc-channels-permissions
|
|
||||||
(fn [{:keys [viewAndPostPermissions viewOnlyPermissions]}]
|
|
||||||
{:view-only (set/rename-keys viewOnlyPermissions {:satisfied :satisfied?})
|
|
||||||
:view-and-post (set/rename-keys viewAndPostPermissions {:satisfied :satisfied?})})))
|
|
||||||
|
|
||||||
(defn <-revealed-accounts-rpc
|
(defn <-revealed-accounts-rpc
|
||||||
[accounts]
|
[accounts]
|
||||||
(mapv
|
(mapv
|
||||||
|
@ -34,8 +27,9 @@
|
||||||
(assoc acc
|
(assoc acc
|
||||||
(name k)
|
(name k)
|
||||||
(-> v
|
(-> v
|
||||||
(assoc :can-post? (:canPost v))
|
(assoc :token-gated? (:tokenGated v)
|
||||||
(dissoc :canPost)
|
:can-post? (:canPost v))
|
||||||
|
(dissoc :canPost :tokenGated)
|
||||||
(update :members walk/stringify-keys))))
|
(update :members walk/stringify-keys))))
|
||||||
{}
|
{}
|
||||||
chats))
|
chats))
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
(ns legacy.status-im.data-store.communities-test
|
|
||||||
(:require
|
|
||||||
[cljs.test :refer [deftest is]]
|
|
||||||
[legacy.status-im.data-store.communities :as sut]))
|
|
||||||
|
|
||||||
(def permissions
|
|
||||||
{"community-id-chat-1"
|
|
||||||
{:viewOnlyPermissions {:satisfied false
|
|
||||||
:permissions {:token-permission-id-01 {:criteria [false]}}}
|
|
||||||
:viewAndPostPermissions {:satisfied true :permissions {}}}
|
|
||||||
"community-id-chat-2"
|
|
||||||
{:viewOnlyPermissions {:satisfied true :permissions {}}
|
|
||||||
:viewAndPostPermissions {:satisfied true :permissions {}}}})
|
|
||||||
|
|
||||||
(deftest rpc->channel-permissions-test
|
|
||||||
(is (= {"community-id-chat-1"
|
|
||||||
{:view-only {:satisfied? false
|
|
||||||
:permissions {:token-permission-id-01 {:criteria [false]}}}
|
|
||||||
:view-and-post {:satisfied? true :permissions {}}}
|
|
||||||
"community-id-chat-2"
|
|
||||||
{:view-only {:satisfied? true :permissions {}}
|
|
||||||
:view-and-post {:satisfied? true :permissions {}}}}
|
|
||||||
(sut/rpc->channel-permissions permissions))))
|
|
|
@ -14,6 +14,7 @@
|
||||||
:canManageUsers :can-manage-users?
|
:canManageUsers :can-manage-users?
|
||||||
:categoryID :category-id
|
:categoryID :category-id
|
||||||
:canPost :can-post?
|
:canPost :can-post?
|
||||||
|
:tokenGated :token-gated?
|
||||||
:isControlNode :is-control-node?
|
:isControlNode :is-control-node?
|
||||||
:pinMessageAllMembersEnabled :pin-message-all-members-enabled
|
:pinMessageAllMembersEnabled :pin-message-all-members-enabled
|
||||||
:isMember :is-member?
|
:isMember :is-member?
|
||||||
|
|
|
@ -21,28 +21,21 @@
|
||||||
(defn handle-community
|
(defn handle-community
|
||||||
[{:keys [db]} [community-js]]
|
[{:keys [db]} [community-js]]
|
||||||
(when community-js
|
(when community-js
|
||||||
(let [{:keys [token-permissions
|
(let [{:keys [clock
|
||||||
token-permissions-check joined id last-opened-at]
|
token-permissions-check joined id last-opened-at]
|
||||||
:as community} (data-store.communities/<-rpc community-js)
|
:as community} (data-store.communities/<-rpc community-js)
|
||||||
has-channel-perm? (fn [id-perm-tuple]
|
|
||||||
(let [{:keys [type]} (second id-perm-tuple)]
|
|
||||||
(or (= type constants/community-token-permission-can-view-channel)
|
|
||||||
(=
|
|
||||||
type
|
|
||||||
constants/community-token-permission-can-view-and-post-channel))))
|
|
||||||
previous-last-opened-at (get-in db [:communities id :last-opened-at])]
|
previous-last-opened-at (get-in db [:communities id :last-opened-at])]
|
||||||
{:db (assoc-in db
|
(when (> clock (get-in db [:communities id :clock]))
|
||||||
[:communities id]
|
{:db (assoc-in db
|
||||||
(assoc community :last-opened-at (max last-opened-at previous-last-opened-at)))
|
[:communities id]
|
||||||
:fx [[:dispatch [:communities/initialize-permission-addresses id]]
|
(assoc community :last-opened-at (max last-opened-at previous-last-opened-at)))
|
||||||
(when (not joined)
|
:fx [[:dispatch [:communities/initialize-permission-addresses id]]
|
||||||
[:dispatch [:chat.ui/spectate-community id]])
|
(when (not joined)
|
||||||
(when (nil? token-permissions-check)
|
[:dispatch [:chat.ui/spectate-community id]])
|
||||||
[:dispatch [:communities/check-permissions-to-join-community id]])
|
(when (nil? token-permissions-check)
|
||||||
(when (some has-channel-perm? token-permissions)
|
[:dispatch [:communities/check-permissions-to-join-community id]])
|
||||||
[:dispatch [:communities/check-all-community-channels-permissions id]])
|
(when joined
|
||||||
(when joined
|
[:dispatch [:communities/get-revealed-accounts id]])]}))))
|
||||||
[:dispatch [:communities/get-revealed-accounts id]])]})))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/handle-community handle-community)
|
(rf/reg-event-fx :communities/handle-community handle-community)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
(:require [cljs.test :refer [deftest is testing]]
|
(:require [cljs.test :refer [deftest is testing]]
|
||||||
[legacy.status-im.mailserver.core :as mailserver]
|
[legacy.status-im.mailserver.core :as mailserver]
|
||||||
matcher-combinators.test
|
matcher-combinators.test
|
||||||
[status-im.constants :as constants]
|
|
||||||
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview.events]
|
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview.events]
|
||||||
[status-im.contexts.communities.events :as events]))
|
[status-im.contexts.communities.events :as events]))
|
||||||
|
|
||||||
|
@ -262,7 +261,7 @@
|
||||||
(-> effects :json-rpc/call first (select-keys [:method :params]))))))))
|
(-> effects :json-rpc/call first (select-keys [:method :params]))))))))
|
||||||
|
|
||||||
(deftest handle-community
|
(deftest handle-community
|
||||||
(let [community {:id community-id}]
|
(let [community {:id community-id :clock 2}]
|
||||||
(testing "given a unjoined community"
|
(testing "given a unjoined community"
|
||||||
(let [effects (events/handle-community {} [community])]
|
(let [effects (events/handle-community {} [community])]
|
||||||
(is (match? community-id
|
(is (match? community-id
|
||||||
|
@ -287,29 +286,10 @@
|
||||||
[[:dispatch [:communities/initialize-permission-addresses community-id]]
|
[[:dispatch [:communities/initialize-permission-addresses community-id]]
|
||||||
[:dispatch [:chat.ui/spectate-community community-id]]]
|
[:dispatch [:chat.ui/spectate-community community-id]]]
|
||||||
(filter some? (:fx effects))))))
|
(filter some? (:fx effects))))))
|
||||||
(testing "given a community with view channel permission"
|
(testing "given a community with lower clock"
|
||||||
(let [community (assoc community
|
(let [effects (events/handle-community {:db {:communities {community-id {:clock 3}}}} [community])]
|
||||||
:token-permissions
|
(is (nil? effects))))
|
||||||
[["perm-id" {:type constants/community-token-permission-can-view-channel}]])
|
(testing "given a community without clock"
|
||||||
|
(let [community (dissoc community :clock)
|
||||||
effects (events/handle-community {} [community])]
|
effects (events/handle-community {} [community])]
|
||||||
(is (match?
|
(is (nil? effects))))))
|
||||||
[[:dispatch [:communities/initialize-permission-addresses community-id]]
|
|
||||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
|
||||||
[:dispatch [:communities/check-permissions-to-join-community community-id]]
|
|
||||||
[:dispatch
|
|
||||||
[:communities/check-all-community-channels-permissions community-id]]]
|
|
||||||
(filter some? (:fx effects))))))
|
|
||||||
|
|
||||||
(testing "given a community with post in channel permission"
|
|
||||||
(let [community (assoc community
|
|
||||||
:token-permissions
|
|
||||||
[["perm-id"
|
|
||||||
{:type constants/community-token-permission-can-view-and-post-channel}]])
|
|
||||||
effects (events/handle-community {} [community])]
|
|
||||||
(is (match?
|
|
||||||
[[:dispatch [:communities/initialize-permission-addresses community-id]]
|
|
||||||
[:dispatch [:chat.ui/spectate-community community-id]]
|
|
||||||
[:dispatch [:communities/check-permissions-to-join-community community-id]]
|
|
||||||
[:dispatch
|
|
||||||
[:communities/check-all-community-channels-permissions community-id]]]
|
|
||||||
(filter some? (:fx effects))))))))
|
|
||||||
|
|
|
@ -1,37 +1,10 @@
|
||||||
(ns status-im.contexts.communities.overview.events
|
(ns status-im.contexts.communities.overview.events
|
||||||
(:require
|
(:require
|
||||||
[legacy.status-im.data-store.communities :as data-store]
|
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/check-all-community-channels-permissions-success
|
|
||||||
(fn [{:keys [db]} [community-id response]]
|
|
||||||
{:db (-> db
|
|
||||||
(assoc-in [:community-channels-permissions community-id]
|
|
||||||
(data-store/rpc->channel-permissions (:channels response)))
|
|
||||||
(assoc-in [:communities/channel-permissions-check community-id] false))}))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/check-all-community-channels-permissions-failed
|
|
||||||
(fn [{:keys [db]} [community-id]]
|
|
||||||
{:db (assoc-in db [:communities/channel-permissions-check community-id] false)}))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/check-all-community-channels-permissions
|
|
||||||
(fn [{:keys [db]} [community-id]]
|
|
||||||
(when (get-in db [:communities community-id])
|
|
||||||
{:db (assoc-in db [:communities/channel-permissions-check community-id] true)
|
|
||||||
:fx [[:json-rpc/call
|
|
||||||
[{:method "wakuext_checkAllCommunityChannelsPermissions"
|
|
||||||
:params [{:CommunityID community-id}]
|
|
||||||
:on-success [:communities/check-all-community-channels-permissions-success community-id]
|
|
||||||
:on-error (fn [error]
|
|
||||||
(rf/dispatch [:communities/check-all-community-channels-permissions-failed
|
|
||||||
community-id])
|
|
||||||
(log/error "failed to check channels permissions"
|
|
||||||
{:error error
|
|
||||||
:community-id community-id
|
|
||||||
:event
|
|
||||||
:communities/check-all-community-channels-permissions}))}]]]})))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/check-permissions-to-join-community-success
|
(rf/reg-event-fx :communities/check-permissions-to-join-community-success
|
||||||
(fn [{:keys [db]} [community-id based-on-client-selection? result]]
|
(fn [{:keys [db]} [community-id based-on-client-selection? result]]
|
||||||
|
|
|
@ -48,15 +48,16 @@
|
||||||
:emoji emoji
|
:emoji emoji
|
||||||
:customization-color community-color
|
:customization-color community-color
|
||||||
:mentions-count mentions-count
|
:mentions-count mentions-count
|
||||||
|
;; NOTE: this is a troolean, nil/true/false have different meaning
|
||||||
:locked? locked?
|
:locked? locked?
|
||||||
:notification notification}
|
:notification notification}
|
||||||
channel-sheet-data {:selected-item (fn [] [quo/channel channel-options])
|
channel-sheet-data {:selected-item (fn [] [quo/channel channel-options])
|
||||||
:content (fn [] sheet-content)}]
|
:content (fn [] sheet-content)}]
|
||||||
[rn/view {:key id}
|
[rn/view {:key id}
|
||||||
[quo/channel
|
[quo/channel
|
||||||
(merge channel-options
|
(assoc channel-options
|
||||||
{:on-press on-press
|
:on-press on-press
|
||||||
:on-long-press #(rf/dispatch [:show-bottom-sheet channel-sheet-data])})]]))
|
:on-long-press #(rf/dispatch [:show-bottom-sheet channel-sheet-data]))]]))
|
||||||
|
|
||||||
(defn- channel-list-component
|
(defn- channel-list-component
|
||||||
[{:keys [on-category-layout community-id community-color on-first-channel-height-changed]}
|
[{:keys [on-category-layout community-id community-color on-first-channel-height-changed]}
|
||||||
|
@ -253,8 +254,7 @@
|
||||||
:description-accessibility-label :community-description}])
|
:description-accessibility-label :community-description}])
|
||||||
|
|
||||||
(defn- community-content
|
(defn- community-content
|
||||||
[id]
|
[_]
|
||||||
(rf/dispatch [:communities/check-all-community-channels-permissions id])
|
|
||||||
(fn [id
|
(fn [id
|
||||||
{:keys [on-category-layout
|
{:keys [on-category-layout
|
||||||
collapsed?
|
collapsed?
|
||||||
|
|
|
@ -181,15 +181,16 @@
|
||||||
(chat.events/public-chat? current-chat)
|
(chat.events/public-chat? current-chat)
|
||||||
(assoc :able-to-send-message? true)
|
(assoc :able-to-send-message? true)
|
||||||
|
|
||||||
|
(and (chat.events/community-chat? current-chat)
|
||||||
|
(get-in community [:chats (subs (:chat-id current-chat) 68) :can-post?]))
|
||||||
|
(assoc :able-to-send-message? true)
|
||||||
|
|
||||||
|
|
||||||
(and (chat.events/group-chat? current-chat)
|
(and (chat.events/group-chat? current-chat)
|
||||||
(group-chats.db/member? my-public-key current-chat))
|
(group-chats.db/member? my-public-key current-chat))
|
||||||
(assoc :able-to-send-message? true
|
(assoc :able-to-send-message? true
|
||||||
:member? true)
|
:member? true)
|
||||||
|
|
||||||
(and (chat.events/community-chat? current-chat)
|
|
||||||
(get-in community [:chats (subs (:chat-id current-chat) 68) :can-post?]))
|
|
||||||
(assoc :able-to-send-message? true)
|
|
||||||
|
|
||||||
(not group-chat)
|
(not group-chat)
|
||||||
(assoc
|
(assoc
|
||||||
:contact-request-state (get-in contacts [chat-id :contact-request-state])
|
:contact-request-state (get-in contacts [chat-id :contact-request-state])
|
||||||
|
|
|
@ -229,42 +229,13 @@
|
||||||
(sort-by :position)
|
(sort-by :position)
|
||||||
(into []))))
|
(into []))))
|
||||||
|
|
||||||
(defn- get-chat-lock-state
|
|
||||||
"Returns the chat lock state.
|
|
||||||
|
|
||||||
- Nil: no lock (there are no permissions for the chat)
|
|
||||||
- True: locked (there are permissions and can-post? is false)
|
|
||||||
- False: unlocked (there are permissions and can-post? is true)"
|
|
||||||
[community-id channels-permissions {chat-id :id}]
|
|
||||||
(let [composite-key (keyword (str community-id chat-id))
|
|
||||||
permissions (get channels-permissions composite-key)
|
|
||||||
{view-only-satisfied? :satisfied?
|
|
||||||
view-only-permissions :permissions} (:view-only permissions)
|
|
||||||
{view-and-post-satisfied? :satisfied?
|
|
||||||
view-and-post-permissions :permissions} (:view-and-post permissions)
|
|
||||||
can-access? (or (and (seq view-only-permissions)
|
|
||||||
view-only-satisfied?)
|
|
||||||
(and (seq view-and-post-permissions)
|
|
||||||
view-and-post-satisfied?))]
|
|
||||||
(if (and (empty? view-only-permissions)
|
|
||||||
(empty? view-and-post-permissions))
|
|
||||||
nil
|
|
||||||
(not can-access?))))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
|
||||||
:communities/community-channels-permissions
|
|
||||||
:<- [:communities/channels-permissions]
|
|
||||||
(fn [channel-permissions [_ community-id]]
|
|
||||||
(get channel-permissions community-id)))
|
|
||||||
|
|
||||||
(defn- reduce-over-categories
|
(defn- reduce-over-categories
|
||||||
[community-id
|
[community-id
|
||||||
categories
|
categories
|
||||||
collapsed-categories
|
collapsed-categories
|
||||||
full-chats-data
|
full-chats-data]
|
||||||
channels-permissions]
|
|
||||||
(fn [acc
|
(fn [acc
|
||||||
[_ {:keys [name categoryID position id emoji] :as chat}]]
|
[_ {:keys [name categoryID position id emoji can-post? token-gated?]}]]
|
||||||
(let [category-id (if (seq categoryID) categoryID constants/empty-category-id)
|
(let [category-id (if (seq categoryID) categoryID constants/empty-category-id)
|
||||||
{:keys [unviewed-messages-count
|
{:keys [unviewed-messages-count
|
||||||
unviewed-mentions-count
|
unviewed-mentions-count
|
||||||
|
@ -286,9 +257,11 @@
|
||||||
:unread-messages? (pos? unviewed-messages-count)
|
:unread-messages? (pos? unviewed-messages-count)
|
||||||
:position position
|
:position position
|
||||||
:mentions-count (or unviewed-mentions-count 0)
|
:mentions-count (or unviewed-mentions-count 0)
|
||||||
:locked? (get-chat-lock-state community-id
|
:can-post? can-post?
|
||||||
channels-permissions
|
;; NOTE: this is a troolean nil->no permissions, true->no access, false ->
|
||||||
chat)
|
;; has access
|
||||||
|
:locked? (when token-gated?
|
||||||
|
(not can-post?))
|
||||||
:id id}]
|
:id id}]
|
||||||
(update-in acc-with-category [category-id :chats] conj categorized-chat))))
|
(update-in acc-with-category [category-id :chats] conj categorized-chat))))
|
||||||
|
|
||||||
|
@ -297,17 +270,14 @@
|
||||||
(fn [[_ community-id]]
|
(fn [[_ community-id]]
|
||||||
[(re-frame/subscribe [:communities/community community-id])
|
[(re-frame/subscribe [:communities/community community-id])
|
||||||
(re-frame/subscribe [:chats/chats])
|
(re-frame/subscribe [:chats/chats])
|
||||||
(re-frame/subscribe [:communities/collapsed-categories-for-community community-id])
|
(re-frame/subscribe [:communities/collapsed-categories-for-community community-id])])
|
||||||
(re-frame/subscribe [:communities/community-channels-permissions community-id])])
|
(fn [[{:keys [categories chats]} full-chats-data collapsed-categories]
|
||||||
(fn [[{:keys [categories chats]} full-chats-data collapsed-categories
|
|
||||||
channels-permissions]
|
|
||||||
[_ community-id]]
|
[_ community-id]]
|
||||||
(let [reduce-fn (reduce-over-categories
|
(let [reduce-fn (reduce-over-categories
|
||||||
community-id
|
community-id
|
||||||
categories
|
categories
|
||||||
collapsed-categories
|
collapsed-categories
|
||||||
full-chats-data
|
full-chats-data)
|
||||||
channels-permissions)
|
|
||||||
categories-and-chats
|
categories-and-chats
|
||||||
(->> chats
|
(->> chats
|
||||||
(reduce reduce-fn {})
|
(reduce reduce-fn {})
|
||||||
|
|
|
@ -84,26 +84,29 @@
|
||||||
:communities
|
:communities
|
||||||
{"0x1" {:id "0x1"
|
{"0x1" {:id "0x1"
|
||||||
:chats {"0x1"
|
:chats {"0x1"
|
||||||
{:id "0x1"
|
{:id "0x1"
|
||||||
:position 1
|
:position 1
|
||||||
:name "chat1"
|
:name "chat1"
|
||||||
:muted? nil
|
:muted? nil
|
||||||
:categoryID "1"
|
:categoryID "1"
|
||||||
:can-post? true}
|
:token-gated? false
|
||||||
|
:can-post? true}
|
||||||
"0x2"
|
"0x2"
|
||||||
{:id "0x2"
|
{:id "0x2"
|
||||||
:position 2
|
:position 2
|
||||||
:name "chat2"
|
:name "chat2"
|
||||||
:muted? nil
|
:muted? nil
|
||||||
:categoryID "1"
|
:categoryID "1"
|
||||||
:can-post? false}
|
:token-gated? true
|
||||||
|
:can-post? false}
|
||||||
"0x3"
|
"0x3"
|
||||||
{:id "0x3"
|
{:id "0x3"
|
||||||
:position 3
|
:position 3
|
||||||
:name "chat3"
|
:name "chat3"
|
||||||
:muted? nil
|
:muted? nil
|
||||||
:categoryID "2"
|
:categoryID "2"
|
||||||
:can-post? true}}
|
:token-gated? true
|
||||||
|
:can-post? true}}
|
||||||
:categories {"1" {:id "1"
|
:categories {"1" {:id "1"
|
||||||
:position 2
|
:position 2
|
||||||
:name "category1"}
|
:name "category1"}
|
||||||
|
@ -112,141 +115,41 @@
|
||||||
:name "category2"}}
|
:name "category2"}}
|
||||||
:joined true}})
|
:joined true}})
|
||||||
(is
|
(is
|
||||||
(= [["2"
|
(match? [["2"
|
||||||
{:id "2"
|
{:id "2"
|
||||||
:name "category2"
|
:name "category2"
|
||||||
:collapsed? nil
|
:collapsed? nil
|
||||||
:position 1
|
:position 1
|
||||||
:chats [{:name "chat3"
|
:chats [{:name "chat3"
|
||||||
:position 3
|
:position 3
|
||||||
:emoji nil
|
:emoji nil
|
||||||
:muted? nil
|
:muted? nil
|
||||||
:locked? nil
|
:locked? false
|
||||||
:id "0x3"
|
:id "0x3"
|
||||||
:unread-messages? false
|
:unread-messages? false
|
||||||
:mentions-count 0}]}]
|
:mentions-count 0}]}]
|
||||||
["1"
|
["1"
|
||||||
{:id "1"
|
{:id "1"
|
||||||
:name "category1"
|
:name "category1"
|
||||||
:collapsed? nil
|
:collapsed? nil
|
||||||
:position 2
|
:position 2
|
||||||
:chats [{:name "chat1"
|
:chats [{:name "chat1"
|
||||||
:emoji nil
|
:emoji nil
|
||||||
:position 1
|
:position 1
|
||||||
:muted? nil
|
:muted? nil
|
||||||
:locked? nil
|
:locked? nil
|
||||||
:id "0x1"
|
:id "0x1"
|
||||||
:unread-messages? false
|
:unread-messages? false
|
||||||
:mentions-count 0}
|
:mentions-count 0}
|
||||||
{:name "chat2"
|
{:name "chat2"
|
||||||
:emoji nil
|
:emoji nil
|
||||||
:position 2
|
:position 2
|
||||||
:muted? nil
|
:muted? nil
|
||||||
:locked? nil
|
:locked? true
|
||||||
:id "0x2"
|
:id "0x2"
|
||||||
:unread-messages? false
|
:unread-messages? false
|
||||||
:mentions-count 0}]}]]
|
:mentions-count 0}]}]]
|
||||||
(rf/sub [sub-name "0x1"]))))
|
(rf/sub [sub-name "0x1"]))))
|
||||||
|
|
||||||
(testing "Channels with categories and token permissions"
|
|
||||||
(swap! rf-db/app-db assoc
|
|
||||||
:community-channels-permissions
|
|
||||||
{community-id
|
|
||||||
{(keyword (str community-id "0x100"))
|
|
||||||
{:view-only {:satisfied? false
|
|
||||||
:permissions {:token-permission-id-01 {:criteria [false]}}}
|
|
||||||
:view-and-post {:satisfied? true :permissions {}}}
|
|
||||||
(keyword (str community-id "0x200"))
|
|
||||||
{:view-only {:satisfied? true :permissions {}}
|
|
||||||
:view-and-post {:satisfied? true :permissions {}}}
|
|
||||||
(keyword (str community-id "0x300"))
|
|
||||||
{:view-only {:satisfied? false :permissions {}}
|
|
||||||
:view-and-post {:satisfied? true
|
|
||||||
:permissions {:token-permission-id-03 {:criteria [true]}}}}
|
|
||||||
(keyword (str community-id "0x400"))
|
|
||||||
{:view-only {:satisfied? true
|
|
||||||
:permissions {}}
|
|
||||||
:view-and-post {:satisfied? false
|
|
||||||
:permissions {:token-permission-id-04 {:criteria [false]}}}}}}
|
|
||||||
|
|
||||||
:communities
|
|
||||||
{community-id {:id community-id
|
|
||||||
:chats {"0x100" {:id "0x100"
|
|
||||||
:position 1
|
|
||||||
:name "chat1"
|
|
||||||
:muted? nil
|
|
||||||
:categoryID "1"
|
|
||||||
:can-post? false}
|
|
||||||
"0x200" {:id "0x200"
|
|
||||||
:position 2
|
|
||||||
:name "chat2"
|
|
||||||
:muted? nil
|
|
||||||
:categoryID "1"
|
|
||||||
:can-post? false}
|
|
||||||
"0x300" {:id "0x300"
|
|
||||||
:position 3
|
|
||||||
:name "chat3"
|
|
||||||
:muted? nil
|
|
||||||
:categoryID "2"
|
|
||||||
:can-post? true}
|
|
||||||
"0x400" {:id "0x400"
|
|
||||||
:position 4
|
|
||||||
:name "chat4"
|
|
||||||
:muted? nil
|
|
||||||
:categoryID "2"
|
|
||||||
:can-post? true}}
|
|
||||||
:categories {"1" {:id "1"
|
|
||||||
:position 2
|
|
||||||
:name "category1"}
|
|
||||||
"2" {:id "2"
|
|
||||||
:position 1
|
|
||||||
:name "category2"}}
|
|
||||||
:joined true}})
|
|
||||||
(is
|
|
||||||
(= [["2"
|
|
||||||
{:id "2"
|
|
||||||
:name "category2"
|
|
||||||
:collapsed? nil
|
|
||||||
:position 1
|
|
||||||
:chats [{:name "chat3"
|
|
||||||
:position 3
|
|
||||||
:emoji nil
|
|
||||||
:muted? nil
|
|
||||||
:locked? false
|
|
||||||
:id "0x300"
|
|
||||||
:unread-messages? false
|
|
||||||
:mentions-count 0}
|
|
||||||
{:name "chat4"
|
|
||||||
:position 4
|
|
||||||
:emoji nil
|
|
||||||
:muted? nil
|
|
||||||
:locked? true
|
|
||||||
:id "0x400"
|
|
||||||
:unread-messages? false
|
|
||||||
:mentions-count 0}]}]
|
|
||||||
["1"
|
|
||||||
{:id "1"
|
|
||||||
:name "category1"
|
|
||||||
:collapsed? nil
|
|
||||||
:position 2
|
|
||||||
:chats [{:name "chat1"
|
|
||||||
:emoji nil
|
|
||||||
:position 1
|
|
||||||
:muted? nil
|
|
||||||
:locked? true
|
|
||||||
:id "0x100"
|
|
||||||
:unread-messages? false
|
|
||||||
:mentions-count 0}
|
|
||||||
{:name "chat2"
|
|
||||||
:emoji nil
|
|
||||||
:position 2
|
|
||||||
:muted? nil
|
|
||||||
:locked? nil
|
|
||||||
:id "0x200"
|
|
||||||
:unread-messages? false
|
|
||||||
:mentions-count 0}]}]]
|
|
||||||
(rf/sub [sub-name "0x1"]))))
|
|
||||||
|
|
||||||
(testing "Channels without categories"
|
(testing "Channels without categories"
|
||||||
(swap! rf-db/app-db assoc
|
(swap! rf-db/app-db assoc
|
||||||
:communities
|
:communities
|
||||||
|
@ -274,7 +177,7 @@
|
||||||
:name "category2"}}
|
:name "category2"}}
|
||||||
:joined true}})
|
:joined true}})
|
||||||
(is
|
(is
|
||||||
(=
|
(match?
|
||||||
[[constants/empty-category-id
|
[[constants/empty-category-id
|
||||||
{:name (i18n/label :t/none)
|
{:name (i18n/label :t/none)
|
||||||
:collapsed? nil
|
:collapsed? nil
|
||||||
|
@ -323,27 +226,27 @@
|
||||||
{"0x10x1" {:unviewed-messages-count 1 :unviewed-mentions-count 2}
|
{"0x10x1" {:unviewed-messages-count 1 :unviewed-mentions-count 2}
|
||||||
"0x10x2" {:unviewed-messages-count 0 :unviewed-mentions-count 0}})
|
"0x10x2" {:unviewed-messages-count 0 :unviewed-mentions-count 0}})
|
||||||
(is
|
(is
|
||||||
(= [["1"
|
(match? [["1"
|
||||||
{:name "category1"
|
{:name "category1"
|
||||||
:id "1"
|
:id "1"
|
||||||
:collapsed? nil
|
:collapsed? nil
|
||||||
:chats [{:name "chat1"
|
:chats [{:name "chat1"
|
||||||
:emoji nil
|
:emoji nil
|
||||||
:position 1
|
:position 1
|
||||||
:locked? nil
|
:locked? nil
|
||||||
:id "0x1"
|
:id "0x1"
|
||||||
:muted? nil
|
:muted? nil
|
||||||
:unread-messages? true
|
:unread-messages? true
|
||||||
:mentions-count 2}
|
:mentions-count 2}
|
||||||
{:name "chat2"
|
{:name "chat2"
|
||||||
:emoji nil
|
:emoji nil
|
||||||
:position 2
|
:position 2
|
||||||
:locked? nil
|
:locked? nil
|
||||||
:muted? nil
|
:muted? nil
|
||||||
:id "0x2"
|
:id "0x2"
|
||||||
:unread-messages? false
|
:unread-messages? false
|
||||||
:mentions-count 0}]}]]
|
:mentions-count 0}]}]]
|
||||||
(rf/sub [sub-name "0x1"])))))
|
(rf/sub [sub-name "0x1"])))))
|
||||||
|
|
||||||
(h/deftest-sub :communities/my-pending-requests-to-join
|
(h/deftest-sub :communities/my-pending-requests-to-join
|
||||||
[sub-name]
|
[sub-name]
|
||||||
|
|
|
@ -141,7 +141,6 @@
|
||||||
(reg-root-key-sub :communities :communities)
|
(reg-root-key-sub :communities :communities)
|
||||||
(reg-root-key-sub :communities/create :communities/create)
|
(reg-root-key-sub :communities/create :communities/create)
|
||||||
(reg-root-key-sub :communities/create-channel :communities/create-channel)
|
(reg-root-key-sub :communities/create-channel :communities/create-channel)
|
||||||
(reg-root-key-sub :communities/channels-permissions :community-channels-permissions)
|
|
||||||
(reg-root-key-sub :communities/requests-to-join :communities/requests-to-join)
|
(reg-root-key-sub :communities/requests-to-join :communities/requests-to-join)
|
||||||
(reg-root-key-sub :communities/community-id-input :communities/community-id-input)
|
(reg-root-key-sub :communities/community-id-input :communities/community-id-input)
|
||||||
(reg-root-key-sub :communities/fetching-community :communities/fetching-community)
|
(reg-root-key-sub :communities/fetching-community :communities/fetching-community)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.176.8",
|
"version": "v0.176.9",
|
||||||
"commit-sha1": "8c0e24dc260031a822604f7a2771f22daea79aa4",
|
"commit-sha1": "a3ad05db58b8af20bf6b7ab852f8603212abac4e",
|
||||||
"src-sha256": "1c6r5gizcvixawl1c0lxd022wg54m5qxw8rr1q1i9221pzbfmmsl"
|
"src-sha256": "10c05kgihczbams3i8fkfm1mh5m61bnsjh255c22m4awc073rg12"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue