[16315] Implement Community Channel option: view channel members and details (#18489)
This commit is contained in:
parent
4e1851d53c
commit
c847cb5d03
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
(defn emoji-size
|
(defn emoji-size
|
||||||
[size]
|
[size]
|
||||||
{:font-size (case size
|
{:text-align :center
|
||||||
|
:font-size (case size
|
||||||
:size-64 24
|
:size-64 24
|
||||||
:size-32 15
|
:size-32 15
|
||||||
11)})
|
11)})
|
||||||
|
|
|
@ -65,8 +65,9 @@
|
||||||
:align-items :center
|
:align-items :center
|
||||||
:background-color (colors/resolve-color customization-color theme)}))
|
:background-color (colors/resolve-color customization-color theme)}))
|
||||||
|
|
||||||
(def indicator-color
|
(defn indicator-color
|
||||||
{:online colors/success-50
|
[]
|
||||||
|
{:online (colors/theme-colors colors/success-50 colors/success-60)
|
||||||
:offline colors/neutral-40})
|
:offline colors/neutral-40})
|
||||||
|
|
||||||
(defn outer
|
(defn outer
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
font-size (get-in style/sizes [size :font-size])
|
font-size (get-in style/sizes [size :font-size])
|
||||||
amount-initials (if (#{:xs :xxs :xxxs} size) 1 2)
|
amount-initials (if (#{:xs :xxs :xxxs} size) 1 2)
|
||||||
sizes (get style/sizes size)
|
sizes (get style/sizes size)
|
||||||
indicator-color (get style/indicator-color (if online? :online :offline))
|
indicator-color (get (style/indicator-color) (if online? :online :offline))
|
||||||
profile-picture-fn (:fn profile-picture)]
|
profile-picture-fn (:fn profile-picture)]
|
||||||
|
|
||||||
[rn/view {:style outer-styles :accessibility-label :user-avatar}
|
[rn/view {:style outer-styles :accessibility-label :user-avatar}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
(ns quo.components.text-combinations.style)
|
(ns quo.components.text-combinations.style
|
||||||
|
(:require [quo.foundations.colors :as colors]))
|
||||||
|
|
||||||
(def title-container
|
(def title-container
|
||||||
{:flex-direction :row
|
{:flex-direction :row
|
||||||
|
@ -6,7 +7,8 @@
|
||||||
:align-items :center})
|
:align-items :center})
|
||||||
|
|
||||||
(def avatar-container
|
(def avatar-container
|
||||||
{:margin-right 9})
|
{:margin-right 9
|
||||||
|
:text-align :center})
|
||||||
|
|
||||||
(def description-description-text
|
(def description-description-text
|
||||||
{:margin-top 8})
|
{:margin-top 8})
|
||||||
|
@ -16,3 +18,15 @@
|
||||||
:letter-spacing 2
|
:letter-spacing 2
|
||||||
:font-size 13
|
:font-size 13
|
||||||
:line-height 20.5})
|
:line-height 20.5})
|
||||||
|
|
||||||
|
(defn textual-emoji
|
||||||
|
[size customization-color theme]
|
||||||
|
{:border-radius size
|
||||||
|
:margin-top -5
|
||||||
|
:border-width 0
|
||||||
|
:border-color :transparent
|
||||||
|
:width size
|
||||||
|
:height size
|
||||||
|
:justify-content :center
|
||||||
|
:align-items :center
|
||||||
|
:background-color (colors/resolve-color customization-color theme 10)})
|
||||||
|
|
|
@ -7,20 +7,23 @@
|
||||||
[react-native.core :as rn]))
|
[react-native.core :as rn]))
|
||||||
|
|
||||||
(defn icon
|
(defn icon
|
||||||
[source size]
|
[{:keys [source size customization-color theme]}]
|
||||||
|
(if customization-color
|
||||||
|
[rn/view {:style (style/textual-emoji size customization-color theme)}
|
||||||
|
[text/text
|
||||||
|
source]]
|
||||||
[rn/image
|
[rn/image
|
||||||
{:source (if (string? source)
|
{:source source
|
||||||
{:uri source}
|
|
||||||
source)
|
|
||||||
:style {:border-radius 50
|
:style {:border-radius 50
|
||||||
:border-width 0
|
:border-width 0
|
||||||
:border-color :transparent
|
:border-color :transparent
|
||||||
:width size
|
:width size
|
||||||
:height size}}])
|
:height size}}]))
|
||||||
|
|
||||||
(defn view-internal
|
(defn view-internal
|
||||||
[{:keys [container-style
|
[{:keys [container-style
|
||||||
title
|
title
|
||||||
|
theme
|
||||||
title-number-of-lines
|
title-number-of-lines
|
||||||
avatar
|
avatar
|
||||||
title-accessibility-label
|
title-accessibility-label
|
||||||
|
@ -29,7 +32,8 @@
|
||||||
button-icon
|
button-icon
|
||||||
button-on-press
|
button-on-press
|
||||||
customization-color
|
customization-color
|
||||||
emoji-hash]
|
emoji-hash
|
||||||
|
emoji]
|
||||||
:or {title-number-of-lines 1}}]
|
:or {title-number-of-lines 1}}]
|
||||||
[rn/view {:style container-style}
|
[rn/view {:style container-style}
|
||||||
[rn/view
|
[rn/view
|
||||||
|
@ -38,7 +42,10 @@
|
||||||
[rn/view {:style style/title-container}
|
[rn/view {:style style/title-container}
|
||||||
(when avatar
|
(when avatar
|
||||||
[rn/view {:style style/avatar-container}
|
[rn/view {:style style/avatar-container}
|
||||||
[icon avatar 32]])
|
[icon {:source avatar :size 32}]])
|
||||||
|
(when emoji
|
||||||
|
[rn/view {:style style/avatar-container}
|
||||||
|
[icon {:source emoji :size 32 :customization-color customization-color :theme theme}]])
|
||||||
[text/text
|
[text/text
|
||||||
{:accessibility-label title-accessibility-label
|
{:accessibility-label title-accessibility-label
|
||||||
:weight :semi-bold
|
:weight :semi-bold
|
||||||
|
|
|
@ -12,5 +12,5 @@
|
||||||
(defn contacts-section-header
|
(defn contacts-section-header
|
||||||
[{:keys [title]}]
|
[{:keys [title]}]
|
||||||
(let [theme (quo.theme/use-theme-value)]
|
(let [theme (quo.theme/use-theme-value)]
|
||||||
[rn/view (style/contacts-section-header theme)
|
[quo/divider-label {:container-style {:background-color (style/contacts-section-header theme)}}
|
||||||
[quo/divider-label title]]))
|
title]))
|
||||||
|
|
|
@ -452,27 +452,29 @@
|
||||||
(let [current-pub-key (rf/sub [:multiaccount/public-key])]
|
(let [current-pub-key (rf/sub [:multiaccount/public-key])]
|
||||||
[quo/action-drawer
|
[quo/action-drawer
|
||||||
[[(view-profile-entry public-key)
|
[[(view-profile-entry public-key)
|
||||||
(remove-from-contacts-entry contact)
|
(when-not (= current-pub-key public-key) (remove-from-contacts-entry contact))
|
||||||
(rename-entry)
|
(when-not (= current-pub-key public-key) (rename-entry))
|
||||||
(show-qr-entry)
|
(show-qr-entry)
|
||||||
(share-profile-entry)]
|
(share-profile-entry)]
|
||||||
[(mark-untrustworthy-entry)
|
[(when-not (= current-pub-key public-key) (mark-untrustworthy-entry))
|
||||||
(block-user-entry contact)]
|
(when-not (= current-pub-key public-key) (block-user-entry contact))]
|
||||||
(when (and admin? chat-id)
|
(when (and admin? chat-id)
|
||||||
[(if (= current-pub-key public-key)
|
[(if (= current-pub-key public-key)
|
||||||
(leave-group-entry contact extra-data)
|
(leave-group-entry contact extra-data)
|
||||||
(remove-from-group-entry contact chat-id))])]]))
|
(remove-from-group-entry contact chat-id))])]]))
|
||||||
|
|
||||||
(defn chat-actions
|
(defn chat-actions
|
||||||
[{:keys [chat-type] :as chat} inside-chat?]
|
([{:keys [chat-type] :as chat} inside-chat? hide-show-members?]
|
||||||
(condp = chat-type
|
(condp = chat-type
|
||||||
constants/one-to-one-chat-type
|
constants/one-to-one-chat-type
|
||||||
[one-to-one-actions chat inside-chat?]
|
[one-to-one-actions chat inside-chat?]
|
||||||
constants/private-group-chat-type
|
constants/private-group-chat-type
|
||||||
[private-group-chat-actions chat inside-chat?]
|
[private-group-chat-actions chat inside-chat?]
|
||||||
constants/community-chat-type
|
constants/community-chat-type
|
||||||
[communities-chat-actions/actions chat inside-chat?]
|
[communities-chat-actions/actions chat inside-chat? hide-show-members?]
|
||||||
nil))
|
nil))
|
||||||
|
([chat inside-chat?]
|
||||||
|
(chat-actions chat inside-chat? nil)))
|
||||||
|
|
||||||
(defn group-details-actions
|
(defn group-details-actions
|
||||||
[{:keys [admins] :as group}]
|
[{:keys [admins] :as group}]
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
(ns status-im.contexts.communities.actions.channel-view-details.style)
|
||||||
|
|
||||||
|
(def channel-actions-wrapper {:height 102})
|
||||||
|
|
||||||
|
(def footer {:margin-top 8})
|
||||||
|
|
||||||
|
(def text-combinations {:margin-top 12 :margin-horizontal 20})
|
||||||
|
|
||||||
|
(def wrapper {:padding 20})
|
||||||
|
|
||||||
|
(def floating-shell-button
|
||||||
|
{:position :absolute
|
||||||
|
:bottom 34
|
||||||
|
:z-index 3})
|
|
@ -0,0 +1,120 @@
|
||||||
|
(ns status-im.contexts.communities.actions.channel-view-details.view
|
||||||
|
(:require [clojure.string :as string]
|
||||||
|
[quo.core :as quo]
|
||||||
|
[quo.theme]
|
||||||
|
[react-native.core :as rn]
|
||||||
|
[status-im.common.contact-list-item.view :as contact-list-item]
|
||||||
|
[status-im.common.contact-list.view :as contact-list]
|
||||||
|
[status-im.common.home.actions.view :as home.actions]
|
||||||
|
[status-im.contexts.communities.actions.channel-view-details.style :as style]
|
||||||
|
[utils.i18n :as i18n]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(defn- contact-item
|
||||||
|
[public-key]
|
||||||
|
(let [show-profile-actions #(rf/dispatch
|
||||||
|
[:show-bottom-sheet
|
||||||
|
{:content (fn [] [home.actions/contact-actions
|
||||||
|
{:public-key public-key}])}])
|
||||||
|
[primary-name secondary-name] (rf/sub [:contacts/contact-two-names-by-identity
|
||||||
|
public-key])
|
||||||
|
{:keys [ens-verified added? compressed-key]} (rf/sub [:contacts/contact-by-address public-key])
|
||||||
|
theme (quo.theme/use-theme-value)]
|
||||||
|
[contact-list-item/contact-list-item
|
||||||
|
{:on-press #(rf/dispatch [:chat.ui/show-profile public-key])
|
||||||
|
:on-long-press show-profile-actions
|
||||||
|
:accessory {:type :options
|
||||||
|
:on-press show-profile-actions}}
|
||||||
|
{:primary-name primary-name
|
||||||
|
:secondary-name secondary-name
|
||||||
|
:compressed-key compressed-key
|
||||||
|
:public-key public-key
|
||||||
|
:ens-verified ens-verified
|
||||||
|
:added? added?}
|
||||||
|
theme]))
|
||||||
|
|
||||||
|
(defn- footer
|
||||||
|
[]
|
||||||
|
[rn/view {:style style/footer}])
|
||||||
|
|
||||||
|
(defn- get-item-layout
|
||||||
|
[_ index]
|
||||||
|
#js {:length 200 :offset (* 200 index) :index index})
|
||||||
|
|
||||||
|
(defn- members
|
||||||
|
[items]
|
||||||
|
[rn/section-list
|
||||||
|
{:key-fn :public-key
|
||||||
|
:content-container-style {:padding-bottom 20}
|
||||||
|
:get-item-layout get-item-layout
|
||||||
|
:content-inset-adjustment-behavior :never
|
||||||
|
:sections items
|
||||||
|
:sticky-section-headers-enabled false
|
||||||
|
:render-section-header-fn contact-list/contacts-section-header
|
||||||
|
:render-section-footer-fn footer
|
||||||
|
:render-fn contact-item
|
||||||
|
:scroll-event-throttle 8}])
|
||||||
|
|
||||||
|
(defn view
|
||||||
|
[_args]
|
||||||
|
(fn []
|
||||||
|
(let [{:keys [chat-id community-id]} (rf/sub [:get-screen-params
|
||||||
|
:screen/chat.view-channel-members-and-details])
|
||||||
|
{:keys [description chat-name emoji muted chat-type color]
|
||||||
|
:as chat} (rf/sub [:chats/chat-by-id chat-id])
|
||||||
|
pins-count (rf/sub [:chats/pin-messages-count chat-id])
|
||||||
|
items (rf/sub [:communities/sorted-community-members-section-list
|
||||||
|
community-id])
|
||||||
|
theme (quo.theme/use-theme-value)]
|
||||||
|
(rn/use-mount (fn []
|
||||||
|
(rf/dispatch [:pin-message/load-pin-messages chat-id])))
|
||||||
|
[:<>
|
||||||
|
[quo/floating-shell-button
|
||||||
|
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
|
||||||
|
:customization-color color
|
||||||
|
:label (i18n/label :t/jump-to)}}
|
||||||
|
style/floating-shell-button]
|
||||||
|
[quo/gradient-cover {:customization-color color :opacity 0.4}]
|
||||||
|
[quo/page-nav
|
||||||
|
{:background :blur
|
||||||
|
:icon-name :i/arrow-left
|
||||||
|
:on-press #(rf/dispatch [:navigate-back])
|
||||||
|
:right-side [{:icon-name :i/options
|
||||||
|
:on-press #(rf/dispatch [:show-bottom-sheet
|
||||||
|
{:content (fn [] [home.actions/chat-actions
|
||||||
|
chat
|
||||||
|
false
|
||||||
|
true])}])}]}]
|
||||||
|
[quo/text-combinations
|
||||||
|
{:container-style style/text-combinations
|
||||||
|
:title [quo/channel-name
|
||||||
|
{:channel-name chat-name
|
||||||
|
:unlocked? true}]
|
||||||
|
:theme theme
|
||||||
|
:emoji (when (not (string/blank? emoji)) (string/trim emoji))
|
||||||
|
:customization-color color
|
||||||
|
:title-accessibility-label :welcome-title
|
||||||
|
:description description
|
||||||
|
:description-accessibility-label :welcome-sub-title}]
|
||||||
|
[rn/view {:style style/wrapper}
|
||||||
|
[rn/view
|
||||||
|
{:style style/channel-actions-wrapper}
|
||||||
|
[quo/channel-actions
|
||||||
|
{:actions
|
||||||
|
[{:big? true
|
||||||
|
:label (i18n/label :t/pinned-messages-2)
|
||||||
|
:customization-color color
|
||||||
|
:icon :i/pin
|
||||||
|
:counter-value pins-count
|
||||||
|
:on-press (fn []
|
||||||
|
(rf/dispatch [:dismiss-keyboard])
|
||||||
|
(rf/dispatch [:pin-message/show-pins-bottom-sheet
|
||||||
|
chat-id]))}
|
||||||
|
{:label (if muted (i18n/label :t/unmute-channel) (i18n/label :t/mute-channel))
|
||||||
|
:customization-color color
|
||||||
|
:icon (if muted :i/muted :i/activity-center)
|
||||||
|
:on-press (fn []
|
||||||
|
(if muted
|
||||||
|
(home.actions/unmute-chat-action chat-id)
|
||||||
|
(home.actions/mute-chat-action chat-id chat-type muted)))}]}]]]
|
||||||
|
[members items color]])))
|
|
@ -30,11 +30,12 @@
|
||||||
(hide-sheet-and-dispatch [:chat.ui/mute chat-id false 0]))
|
(hide-sheet-and-dispatch [:chat.ui/mute chat-id false 0]))
|
||||||
|
|
||||||
(defn- action-view-members-and-details
|
(defn- action-view-members-and-details
|
||||||
[]
|
[community-id chat-id]
|
||||||
{:icon :i/members
|
{:icon :i/members
|
||||||
:accessibility-label :chat-view-members-and-details
|
:accessibility-label :chat-view-members-and-details
|
||||||
:label (i18n/label :t/view-channel-members-and-details)
|
:label (i18n/label :t/view-channel-members-and-details)
|
||||||
:on-press not-implemented/alert})
|
:on-press #(rf/dispatch [:navigate-to :screen/chat.view-channel-members-and-details
|
||||||
|
{:community-id community-id :chat-id chat-id}])})
|
||||||
|
|
||||||
(defn- action-token-requirements
|
(defn- action-token-requirements
|
||||||
[]
|
[]
|
||||||
|
@ -110,7 +111,7 @@
|
||||||
:label (i18n/label :t/share-channel)})
|
:label (i18n/label :t/share-channel)})
|
||||||
|
|
||||||
(defn actions
|
(defn actions
|
||||||
[{:keys [locked? chat-id]} inside-chat?]
|
[{:keys [locked? chat-id community-id]} inside-chat? hide-view-members?]
|
||||||
(let [{:keys [muted muted-till chat-type]} (rf/sub [:chats/chat-by-id chat-id])]
|
(let [{:keys [muted muted-till chat-type]} (rf/sub [:chats/chat-by-id chat-id])]
|
||||||
(cond
|
(cond
|
||||||
locked?
|
locked?
|
||||||
|
@ -122,7 +123,7 @@
|
||||||
|
|
||||||
(and (not inside-chat?) (not locked?))
|
(and (not inside-chat?) (not locked?))
|
||||||
[quo/action-drawer
|
[quo/action-drawer
|
||||||
[[(action-view-members-and-details)
|
[[(when-not hide-view-members? (action-view-members-and-details community-id chat-id))
|
||||||
(action-mark-as-read)
|
(action-mark-as-read)
|
||||||
(action-toggle-muted chat-id muted muted-till chat-type)
|
(action-toggle-muted chat-id muted muted-till chat-type)
|
||||||
(action-notification-settings)
|
(action-notification-settings)
|
||||||
|
@ -133,7 +134,7 @@
|
||||||
|
|
||||||
(and inside-chat? (not locked?))
|
(and inside-chat? (not locked?))
|
||||||
[quo/action-drawer
|
[quo/action-drawer
|
||||||
[[(action-view-members-and-details)
|
[[(action-view-members-and-details community-id chat-id)
|
||||||
(action-token-requirements)
|
(action-token-requirements)
|
||||||
(action-mark-as-read)
|
(action-mark-as-read)
|
||||||
(action-toggle-muted chat-id muted muted-till chat-type)
|
(action-toggle-muted chat-id muted muted-till chat-type)
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
(oops/oget event "nativeEvent.layout.y"))
|
(oops/oget event "nativeEvent.layout.y"))
|
||||||
|
|
||||||
(defn- channel-chat-item
|
(defn- channel-chat-item
|
||||||
[community-id community-color
|
[community-id
|
||||||
{:keys [name emoji muted? id mentions-count unread-messages? on-press locked?] :as chat}]
|
{:keys [name emoji muted? id mentions-count unread-messages? on-press locked? color] :as chat}]
|
||||||
(let [sheet-content [actions/chat-actions
|
(let [sheet-content [actions/chat-actions
|
||||||
(assoc chat
|
(assoc chat
|
||||||
:chat-type constants/community-chat-type
|
:chat-type constants/community-chat-type
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
:else nil)
|
:else nil)
|
||||||
channel-options {:name name
|
channel-options {:name name
|
||||||
:emoji emoji
|
:emoji emoji
|
||||||
:customization-color community-color
|
:customization-color color
|
||||||
:mentions-count mentions-count
|
:mentions-count mentions-count
|
||||||
;; NOTE: this is a troolean, nil/true/false have different meaning
|
;; NOTE: this is a troolean, nil/true/false have different meaning
|
||||||
:locked? locked?
|
:locked? locked?
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
: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 on-first-channel-height-changed]}
|
||||||
channels-list]
|
channels-list]
|
||||||
[rn/view
|
[rn/view
|
||||||
{:on-layout #(on-first-channel-height-changed
|
{:on-layout #(on-first-channel-height-changed
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
[rn/view {:style {:padding-horizontal 8}}
|
[rn/view {:style {:padding-horizontal 8}}
|
||||||
(for [chat chats]
|
(for [chat chats]
|
||||||
^{:key (:id chat)}
|
^{:key (:id chat)}
|
||||||
[channel-chat-item community-id community-color chat])])])])
|
[channel-chat-item community-id chat])])])])
|
||||||
|
|
||||||
(defn- get-access-type
|
(defn- get-access-type
|
||||||
[access]
|
[access]
|
||||||
|
@ -254,7 +254,7 @@
|
||||||
{:keys [on-category-layout
|
{:keys [on-category-layout
|
||||||
collapsed?
|
collapsed?
|
||||||
on-first-channel-height-changed]}]
|
on-first-channel-height-changed]}]
|
||||||
(let [{:keys [name description joined spectated images tags color id membership-permissions?]
|
(let [{:keys [name description joined spectated images tags id membership-permissions?]
|
||||||
:as community}
|
:as community}
|
||||||
(rf/sub [:communities/community id])
|
(rf/sub [:communities/community id])
|
||||||
joined-or-spectated (or joined spectated)
|
joined-or-spectated (or joined spectated)
|
||||||
|
@ -275,7 +275,6 @@
|
||||||
[channel-list-component
|
[channel-list-component
|
||||||
{:on-category-layout on-category-layout
|
{:on-category-layout on-category-layout
|
||||||
:community-id id
|
:community-id id
|
||||||
:community-color color
|
|
||||||
:on-first-channel-height-changed on-first-channel-height-changed}
|
:on-first-channel-height-changed on-first-channel-height-changed}
|
||||||
(add-handlers-to-categorized-chats id chats-by-category joined-or-spectated)])])))
|
(add-handlers-to-categorized-chats id chats-by-category joined-or-spectated)])])))
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
[status-im.contexts.communities.actions.accounts-selection.view :as communities.accounts-selection]
|
[status-im.contexts.communities.actions.accounts-selection.view :as communities.accounts-selection]
|
||||||
[status-im.contexts.communities.actions.addresses-for-permissions.view :as addresses-for-permissions]
|
[status-im.contexts.communities.actions.addresses-for-permissions.view :as addresses-for-permissions]
|
||||||
[status-im.contexts.communities.actions.airdrop-addresses.view :as airdrop-addresses]
|
[status-im.contexts.communities.actions.airdrop-addresses.view :as airdrop-addresses]
|
||||||
|
[status-im.contexts.communities.actions.channel-view-details.view :as
|
||||||
|
channel-view-channel-members-and-details]
|
||||||
[status-im.contexts.communities.actions.request-to-join.view :as join-menu]
|
[status-im.contexts.communities.actions.request-to-join.view :as join-menu]
|
||||||
[status-im.contexts.communities.actions.share-community-channel.view :as share-community-channel]
|
[status-im.contexts.communities.actions.share-community-channel.view :as share-community-channel]
|
||||||
[status-im.contexts.communities.discover.view :as communities.discover]
|
[status-im.contexts.communities.discover.view :as communities.discover]
|
||||||
|
@ -141,6 +143,10 @@
|
||||||
:options {:insets {:top? true}}
|
:options {:insets {:top? true}}
|
||||||
:component communities.accounts-selection/view}
|
:component communities.accounts-selection/view}
|
||||||
|
|
||||||
|
{:name :screen/chat.view-channel-members-and-details
|
||||||
|
:options {:insets {:top? true}}
|
||||||
|
:component channel-view-channel-members-and-details/view}
|
||||||
|
|
||||||
{:name :addresses-for-permissions
|
{:name :addresses-for-permissions
|
||||||
:options {:insets {:top? true}}
|
:options {:insets {:top? true}}
|
||||||
:component addresses-for-permissions/view}
|
:component addresses-for-permissions/view}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
(ns status-im.subs.chat.utils
|
||||||
|
(:require [status-im.constants :as constants]))
|
||||||
|
|
||||||
|
(defn online?
|
||||||
|
[visibility-status-type]
|
||||||
|
(or (= visibility-status-type constants/visibility-status-automatic)
|
||||||
|
(= visibility-status-type constants/visibility-status-always-online)))
|
|
@ -107,6 +107,12 @@
|
||||||
(fn [chats [_ chat-id]]
|
(fn [chats [_ chat-id]]
|
||||||
(get chats chat-id)))
|
(get chats chat-id)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:chats/chat-members-by-id
|
||||||
|
:<- [:chats/chats]
|
||||||
|
(fn [chats [_ chat-id]]
|
||||||
|
(get-in chats [chat-id :members])))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:chats/muted
|
:chats/muted
|
||||||
(fn [[_ chat-id] _]
|
(fn [[_ chat-id] _]
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
|
[status-im.subs.chat.utils :as subs.utils]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.money :as money]))
|
[utils.money :as money]))
|
||||||
|
|
||||||
|
@ -65,12 +66,22 @@
|
||||||
(fn [[{:keys [members]}] _]
|
(fn [[{:keys [members]}] _]
|
||||||
members))
|
members))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(defn- keys->names
|
||||||
:communities/current-community-members
|
[public-keys profile]
|
||||||
:<- [:chats/current-chat]
|
(reduce (fn [acc contact-identity]
|
||||||
:<- [:communities]
|
(assoc acc
|
||||||
(fn [[{:keys [community-id]} communities]]
|
contact-identity
|
||||||
(get-in communities [community-id :members])))
|
(when (= (:public-key profile) contact-identity)
|
||||||
|
(:primary-name profile)
|
||||||
|
contact-identity)))
|
||||||
|
{}
|
||||||
|
public-keys))
|
||||||
|
|
||||||
|
(defn- sort-members-by-name
|
||||||
|
[names descending? members]
|
||||||
|
(if descending?
|
||||||
|
(sort-by #(get names (first %)) #(compare %2 %1) members)
|
||||||
|
(sort-by #(get names (first %)) members)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/sorted-community-members
|
:communities/sorted-community-members
|
||||||
|
@ -79,18 +90,39 @@
|
||||||
members (re-frame/subscribe [:communities/community-members community-id])]
|
members (re-frame/subscribe [:communities/community-members community-id])]
|
||||||
[profile members]))
|
[profile members]))
|
||||||
(fn [[profile members] _]
|
(fn [[profile members] _]
|
||||||
(let [names (reduce (fn [acc contact-identity]
|
(let [names (keys->names (keys members) profile)]
|
||||||
(assoc acc
|
|
||||||
contact-identity
|
|
||||||
(when (= (:public-key profile) contact-identity)
|
|
||||||
(:primary-name profile)
|
|
||||||
contact-identity)))
|
|
||||||
{}
|
|
||||||
(keys members))]
|
|
||||||
(->> members
|
(->> members
|
||||||
(sort-by #(get names (get % 0)))
|
(sort-members-by-name names false)
|
||||||
(sort-by #(visibility-status-utils/visibility-status-order (get % 0)))))))
|
(sort-by #(visibility-status-utils/visibility-status-order (get % 0)))))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:communities/sorted-community-members-section-list
|
||||||
|
(fn [[_ community-id]]
|
||||||
|
(let [profile (re-frame/subscribe [:profile/profile])
|
||||||
|
members (re-frame/subscribe [:communities/community-members
|
||||||
|
community-id])
|
||||||
|
visibility-status-updates (re-frame/subscribe
|
||||||
|
[:visibility-status-updates])
|
||||||
|
my-status-update (re-frame/subscribe
|
||||||
|
[:multiaccount/current-user-visibility-status])]
|
||||||
|
[profile members visibility-status-updates my-status-update]))
|
||||||
|
(fn [[profile members visibility-status-updates my-status-update] _]
|
||||||
|
(let [online? (fn [public-key]
|
||||||
|
(let [{visibility-status-type :status-type}
|
||||||
|
(if (or (string/blank? (:public-key profile))
|
||||||
|
(= (:public-key profile) public-key))
|
||||||
|
my-status-update
|
||||||
|
(get visibility-status-updates public-key))]
|
||||||
|
(subs.utils/online? visibility-status-type)))
|
||||||
|
names (keys->names (keys members) profile)]
|
||||||
|
(->> members
|
||||||
|
(sort-members-by-name names true)
|
||||||
|
keys
|
||||||
|
(group-by online?)
|
||||||
|
(map (fn [[k v]]
|
||||||
|
{:title (if k (i18n/label :t/online) (i18n/label :t/offline))
|
||||||
|
:data v}))))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/featured-contract-communities
|
:communities/featured-contract-communities
|
||||||
:<- [:contract-communities]
|
:<- [:contract-communities]
|
||||||
|
@ -272,7 +304,8 @@
|
||||||
(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
|
||||||
muted]} (get full-chats-data
|
muted
|
||||||
|
color]} (get full-chats-data
|
||||||
(str community-id id))
|
(str community-id id))
|
||||||
acc-with-category (if (get acc category-id)
|
acc-with-category (if (get acc category-id)
|
||||||
acc
|
acc
|
||||||
|
@ -298,7 +331,8 @@
|
||||||
;; -> has access
|
;; -> has access
|
||||||
:locked? locked?
|
:locked? locked?
|
||||||
:hide-if-permissions-not-met? (and hide-if-permissions-not-met? locked?)
|
:hide-if-permissions-not-met? (and hide-if-permissions-not-met? locked?)
|
||||||
:id id}]
|
:id id
|
||||||
|
:color color}]
|
||||||
(update-in acc-with-category [category-id :chats] conj categorized-chat))))
|
(update-in acc-with-category [category-id :chats] conj categorized-chat))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
[re-frame.db :as rf-db]
|
[re-frame.db :as rf-db]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
status-im.subs.communities
|
status-im.subs.communities
|
||||||
|
[status-im.subs.profile-test :as profile-test]
|
||||||
[test-helpers.unit :as h]
|
[test-helpers.unit :as h]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
@ -482,3 +483,52 @@
|
||||||
(is
|
(is
|
||||||
(match? []
|
(match? []
|
||||||
(rf/sub [sub-name community-id]))))))
|
(rf/sub [sub-name community-id]))))))
|
||||||
|
|
||||||
|
(h/deftest-sub :communities/sorted-community-members-section-list
|
||||||
|
[sub-name]
|
||||||
|
(testing "returns sorted community members per online status"
|
||||||
|
(let [token-image-eth "data:image/jpeg;base64,/9j/2w"
|
||||||
|
community {:id community-id
|
||||||
|
:permissions {:access 3}
|
||||||
|
:token-images {"ETH" token-image-eth}
|
||||||
|
:name "Community super name"
|
||||||
|
:chats {"89f98a1e-6776-4e5f-8626-8ab9f855253f"
|
||||||
|
{:description "x"
|
||||||
|
:emoji "🎲"
|
||||||
|
:permissions {:access 1}
|
||||||
|
:color "#88B0FF"
|
||||||
|
:name "random"
|
||||||
|
:categoryID "0c3c64e7-d56e-439b-a3fb-a946d83cb056"
|
||||||
|
:id "89f98a1e-6776-4e5f-8626-8ab9f855253f"
|
||||||
|
:position 4
|
||||||
|
:can-post? false
|
||||||
|
:members {"0x04" {"roles" [1]}}}
|
||||||
|
"a076358e-4638-470e-a3fb-584d0a542ce6"
|
||||||
|
{:description "General channel for the community"
|
||||||
|
:emoji "🥔"
|
||||||
|
:permissions {:access 1}
|
||||||
|
:color "#4360DF"
|
||||||
|
:name "general"
|
||||||
|
:categoryID "0c3c64e7-d56e-439b-a3fb-a946d83cb056"
|
||||||
|
:id "a076358e-4638-470e-a3fb-584d0a542ce6"
|
||||||
|
:position 0
|
||||||
|
:can-post? false
|
||||||
|
:members {"0x04" {"roles" [1]}}}}
|
||||||
|
:members {"0x01" {"roles" [1]}
|
||||||
|
"0x02" {"roles" [1]}
|
||||||
|
"0x03" {"roles" [1]}
|
||||||
|
"0x04" {"roles" [1]}}
|
||||||
|
:can-request-access? false
|
||||||
|
:outroMessage "bla"
|
||||||
|
:verified false}]
|
||||||
|
(swap! rf-db/app-db assoc-in [:communities community-id] community)
|
||||||
|
(swap! rf-db/app-db assoc :profile/profile profile-test/sample-profile)
|
||||||
|
(swap! rf-db/app-db assoc
|
||||||
|
:visibility-status-updates
|
||||||
|
{"0x01" {:status-type constants/visibility-status-always-online}
|
||||||
|
"0x02" {:status-type constants/visibility-status-always-online}})
|
||||||
|
(is (= [{:title (i18n/label :t/online)
|
||||||
|
:data ["0x01" "0x02"]}
|
||||||
|
{:title (i18n/label :t/offline)
|
||||||
|
:data ["0x03" "0x04"]}]
|
||||||
|
(rf/sub [sub-name community-id]))))))
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
[legacy.status-im.utils.build :as build]
|
[legacy.status-im.utils.build :as build]
|
||||||
[legacy.status-im.utils.mobile-sync :as mobile-network-utils]
|
[legacy.status-im.utils.mobile-sync :as mobile-network-utils]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.constants :as constants]
|
[status-im.subs.chat.utils :as chat.utils]
|
||||||
[utils.ethereum.chain :as chain]))
|
[utils.ethereum.chain :as chain]))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
|
@ -25,8 +25,7 @@
|
||||||
[(re-frame/subscribe [:visibility-status-updates/visibility-status-update public-key])])
|
[(re-frame/subscribe [:visibility-status-updates/visibility-status-update public-key])])
|
||||||
(fn [[status-update]]
|
(fn [[status-update]]
|
||||||
(let [visibility-status-type (:status-type status-update)]
|
(let [visibility-status-type (:status-type status-update)]
|
||||||
(or (= visibility-status-type constants/visibility-status-automatic)
|
(chat.utils/online? visibility-status-type))))
|
||||||
(= visibility-status-type constants/visibility-status-always-online)))))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:multiaccount/logged-in?
|
:multiaccount/logged-in?
|
||||||
|
|
|
@ -191,6 +191,7 @@
|
||||||
[:map
|
[:map
|
||||||
[:color string?]
|
[:color string?]
|
||||||
[:theme :schema.common/theme]
|
[:theme :schema.common/theme]
|
||||||
|
[:background-color {:optional true} [:maybe string?]]
|
||||||
[:size number?]
|
[:size number?]
|
||||||
[:ratio float?]
|
[:ratio float?]
|
||||||
[:uppercase-ratio number?]
|
[:uppercase-ratio number?]
|
||||||
|
|
|
@ -1496,7 +1496,7 @@
|
||||||
"view-gitcoin": "View in Gitcoin",
|
"view-gitcoin": "View in Gitcoin",
|
||||||
"view-members": "View members",
|
"view-members": "View members",
|
||||||
"view-profile": "View profile",
|
"view-profile": "View profile",
|
||||||
"view-channel-members-and-details": "View channel member and details",
|
"view-channel-members-and-details": "View channel members and details",
|
||||||
"view-details": "View Details",
|
"view-details": "View Details",
|
||||||
"view-signing": "View signing phrase",
|
"view-signing": "View signing phrase",
|
||||||
"view-superrare": "View in SuperRare",
|
"view-superrare": "View in SuperRare",
|
||||||
|
@ -2573,5 +2573,7 @@
|
||||||
"key-name-error-emoji": "Emojis are not allowed",
|
"key-name-error-emoji": "Emojis are not allowed",
|
||||||
"key-name-error-special-char": "Special characters are not allowed",
|
"key-name-error-special-char": "Special characters are not allowed",
|
||||||
"display": "Display",
|
"display": "Display",
|
||||||
"testnet-mode-enabled": "Testnet mode enabled"
|
"testnet-mode-enabled": "Testnet mode enabled",
|
||||||
|
"online-community-member": "Online",
|
||||||
|
"offline-community-member": "Offline"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue