diff --git a/src/legacy/status_im/data_store/chats.cljs b/src/legacy/status_im/data_store/chats.cljs index 9099f2aaae..8af5ecf6f8 100644 --- a/src/legacy/status_im/data_store/chats.cljs +++ b/src/legacy/status_im/data_store/chats.cljs @@ -70,20 +70,21 @@ (defn <-rpc [chat] (-> chat - (set/rename-keys {:id :chat-id - :communityId :community-id - :syncedFrom :synced-from - :syncedTo :synced-to - :membershipUpdateEvents :membership-update-events - :deletedAtClockValue :deleted-at-clock-value - :chatType :chat-type - :unviewedMessagesCount :unviewed-messages-count - :unviewedMentionsCount :unviewed-mentions-count - :lastMessage :last-message - :lastClockValue :last-clock-value - :invitationAdmin :invitation-admin - :profile :profile-public-key - :muteTill :muted-till}) + (set/rename-keys {:id :chat-id + :communityId :community-id + :syncedFrom :synced-from + :syncedTo :synced-to + :membershipUpdateEvents :membership-update-events + :deletedAtClockValue :deleted-at-clock-value + :chatType :chat-type + :unviewedMessagesCount :unviewed-messages-count + :unviewedMentionsCount :unviewed-mentions-count + :lastMessage :last-message + :lastClockValue :last-clock-value + :invitationAdmin :invitation-admin + :profile :profile-public-key + :muteTill :muted-till + :hideIfPermissionsNotMet :hide-if-permissions-not-met?}) rpc->type unmarshal-members (update :last-message #(when % (messages/<-rpc %))) @@ -92,38 +93,40 @@ (defn <-rpc-js [^js chat] - (-> {:name (.-name chat) - :description (.-description chat) - :color (<-color (.-color chat)) - :emoji (.-emoji chat) - :timestamp (.-timestamp chat) - :alias (.-alias chat) - :muted (.-muted chat) - :joined (.-joined chat) - :muted-till (.-muteTill chat) - :chat-id (.-id chat) - :community-id (.-communityId chat) - :synced-from (.-syncedFrom chat) - :synced-to (.-syncedTo chat) - :deleted-at-clock-value (.-deletedAtClockValue chat) - :chat-type (.-chatType chat) - :unviewed-messages-count (.-unviewedMessagesCount chat) - :unviewed-mentions-count (.-unviewedMentionsCount chat) - :last-message {:content {:text (.-text chat) - :parsed-text (types/js->clj (.-parsedText chat)) - :response-to (.-responseTo chat)} - :content-type (.-contentType chat) - :community-id (.-contentCommunityId chat) - :outgoing (boolean (.-outgoingStatus chat)) - :album-images-count (.-albumImagesCount chat) - :from (.-from chat) - :deleted? (.-deleted chat) - :deleted-for-me? (.-deletedForMe chat)} - :last-clock-value (.-lastClockValue chat) - :profile-public-key (.-profile chat) - :highlight (.-highlight chat) - :active (.-active chat) - :members (types/js->clj (.-members chat))} + (-> {:name (.-name chat) + :description (.-description chat) + :color (<-color (.-color chat)) + :emoji (.-emoji chat) + :timestamp (.-timestamp chat) + :alias (.-alias chat) + :muted (.-muted chat) + :joined (.-joined chat) + :muted-till (.-muteTill chat) + :chat-id (.-id chat) + :community-id (.-communityId chat) + :synced-from (.-syncedFrom chat) + :synced-to (.-syncedTo chat) + :deleted-at-clock-value (.-deletedAtClockValue chat) + :chat-type (.-chatType chat) + :unviewed-messages-count (.-unviewedMessagesCount chat) + :unviewed-mentions-count (.-unviewedMentionsCount chat) + :last-message {:content {:text (.-text chat) + :parsed-text (types/js->clj (.-parsedText + chat)) + :response-to (.-responseTo chat)} + :content-type (.-contentType chat) + :community-id (.-contentCommunityId chat) + :outgoing (boolean (.-outgoingStatus chat)) + :album-images-count (.-albumImagesCount chat) + :from (.-from chat) + :deleted? (.-deleted chat) + :deleted-for-me? (.-deletedForMe chat)} + :last-clock-value (.-lastClockValue chat) + :profile-public-key (.-profile chat) + :highlight (.-highlight chat) + :active (.-active chat) + :members (types/js->clj (.-members chat)) + :hide-if-permissions-not-met (.-hideIfPermissionsNotMet chat)} rpc->type unmarshal-members)) diff --git a/src/legacy/status_im/data_store/communities.cljs b/src/legacy/status_im/data_store/communities.cljs index 32dfb5a113..e6e7168fdc 100644 --- a/src/legacy/status_im/data_store/communities.cljs +++ b/src/legacy/status_im/data_store/communities.cljs @@ -27,10 +27,11 @@ (assoc acc (name k) (-> v - (assoc :token-gated? (:tokenGated v) - :can-post? (:canPost v) - :can-view? (:canView v)) - (dissoc :canPost :tokenGated :canView) + (assoc :token-gated? (:tokenGated v) + :can-post? (:canPost v) + :can-view? (:canView v) + :hide-if-permissions-not-met? (:hideIfPermissionsNotMet v)) + (dissoc :canPost :tokenGated :canView :hideIfPermissionsNotMet) (update :members walk/stringify-keys)))) {} chats)) diff --git a/src/status_im/subs/communities.cljs b/src/status_im/subs/communities.cljs index 0b8a00d33c..70bff455ca 100644 --- a/src/status_im/subs/communities.cljs +++ b/src/status_im/subs/communities.cljs @@ -243,7 +243,8 @@ emoji can-view? can-post? - token-gated?]}]] + token-gated? + hide-if-permissions-not-met?]}]] (let [category-id (if (seq categoryID) categoryID constants/empty-category-id) {:keys [unviewed-messages-count unviewed-mentions-count @@ -259,19 +260,21 @@ :collapsed? (get collapsed-categories category-id) :chats []))) - categorized-chat {:name name - :emoji emoji - :muted? muted - :unread-messages? (pos? unviewed-messages-count) - :position position - :mentions-count (or unviewed-mentions-count 0) - :can-post? can-post? + locked? (when token-gated? + (and (not can-view?) + (not can-post?))) + categorized-chat {:name name + :emoji emoji + :muted? muted + :unread-messages? (pos? unviewed-messages-count) + :position position + :mentions-count (or unviewed-mentions-count 0) + :can-post? can-post? ;; NOTE: this is a troolean nil->no permissions, true->no access, false ;; -> has access - :locked? (when token-gated? - (and (not can-view?) - (not can-post?))) - :id id}] + :locked? locked? + :hide-if-permissions-not-met? (and hide-if-permissions-not-met? locked?) + :id id}] (update-in acc-with-category [category-id :chats] conj categorized-chat)))) (re-frame/reg-sub @@ -292,7 +295,12 @@ (reduce reduce-fn {}) (sort-by (comp :position second)) (map (fn [[k v]] - [k (update v :chats #(sort-by :position %))])))] + [k + (-> v + (update :chats #(sort-by :position %)) + (update :chats + #(filter (comp not :hide-if-permissions-not-met?) + %)))])))] categories-and-chats))) (re-frame/reg-sub