feat: support community that all members allowed to pin (#15197)

This commit is contained in:
yqrashawn 2023-03-02 18:43:21 +08:00 committed by GitHub
parent f731f75fca
commit 4190dfd26b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 34 deletions

View File

@ -71,7 +71,11 @@
:canDeleteMessageForEveryone :can-delete-message-for-everyone?
:canJoin :can-join?
:requestedToJoinAt :requested-to-join-at
:isMember :is-member?})
:isMember :is-member?
:adminSettings :admin-settings})
(update :admin-settings
set/rename-keys
{:pinMessageAllMembersEnabled :pin-message-all-members-enabled?})
(update :members walk/stringify-keys)
(update :chats <-chats-rpc)
(update :categories <-categories-rpc)))

View File

@ -72,16 +72,20 @@
"compute data used to render message list, including pinned message list and message list in chats"
[{:keys [group-chat chat-id public? community-id admins space-keeper show-input? edit-enabled
in-pinned-view?]}]
(let [current-public-key (rf/sub [:multiaccount/public-key])
{:keys [can-delete-message-for-everyone?] :as community} (rf/sub [:communities/community
community-id])
group-admin? (get admins current-public-key)
community-admin? (when community (community :admin))
message-pin-enabled (and (not public?)
(or (not group-chat)
(and group-chat
(or group-admin?
community-admin?))))]
(let [current-public-key (rf/sub [:multiaccount/public-key])
{:keys [can-delete-message-for-everyone?
admin-settings]
:as community} (rf/sub [:communities/community
community-id])
{:keys [pin-message-all-members-enabled?]} admin-settings
group-admin? (get admins current-public-key)
community-admin? (when community (community :admin))
message-pin-enabled (and (not public?)
(or (not group-chat)
(and group-chat
(or group-admin?
pin-message-all-members-enabled?
community-admin?))))]
{:group-chat group-chat
:group-admin? group-admin?
:public? public?

View File

@ -3,8 +3,8 @@
[status-im.chat.models.reactions :as models.reactions]
[status-im2.constants :as constants]
[status-im2.contexts.chat.messages.list.events :as models.message-list]
[utils.i18n :as i18n]
[utils.datetime :as datetime]))
[utils.datetime :as datetime]
[utils.i18n :as i18n]))
(defn intersperse-datemark
"Reduce step which expects the input list of messages to be sorted by clock value.
@ -192,7 +192,6 @@
(sort-by :pinned-at sort-pinned pin-messages-vals))))
(re-frame/reg-sub
:chats/pin-modal
:<- [:messages/pin-modal]
@ -220,32 +219,12 @@
(fn [pagination-info [_ chat-id]]
(get-in pagination-info [chat-id :loading-messages?])))
(re-frame/reg-sub
:chats/loading-pin-messages?
:<- [:messages/pagination-info]
(fn [pagination-info [_ chat-id]]
(get-in pagination-info [chat-id :loading-pin-messages?])))
(re-frame/reg-sub
:chats/message-list
:<- [:messages/message-lists]
(fn [message-lists [_ chat-id]]
(get message-lists chat-id)))
(re-frame/reg-sub
:chats/pin-message-list
:<- [:messages/pin-message-lists]
(fn [pin-message-lists [_ chat-id]]
(get pin-message-lists chat-id)))
(re-frame/reg-sub
:chats/chat-no-messages?
(fn [[_ chat-id] _]
(re-frame/subscribe [:chats/chat-messages chat-id]))
(fn [messages]
(empty? messages)))
(re-frame/reg-sub
:chats/raw-chat-messages-stream
(fn [[_ chat-id] _]