Allow owner/admin to delete messages of a community (#14366)

This commit is contained in:
frank 2022-12-02 20:13:02 +08:00 committed by GitHub
parent f3ad8beb6d
commit f7af7ca25d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 278 additions and 226 deletions

View File

@ -26,12 +26,12 @@
(def featured
[{:name "Status"
:id constants/status-community-id}])
:id constants/status-community-id}])
(defn <-request-to-join-community-rpc [r]
(clojure.set/rename-keys r {:communityId :community-id
:publicKey :public-key
:chatId :chat-id}))
:publicKey :public-key
:chatId :chat-id}))
(defn <-requests-to-join-community-rpc [requests]
(reduce (fn [acc r]
@ -60,11 +60,12 @@
(defn <-rpc [c]
(-> c
(clojure.set/rename-keys {:canRequestAccess :can-request-access?
:canManageUsers :can-manage-users?
:canJoin :can-join?
:requestedToJoinAt :requested-to-join-at
:isMember :is-member?})
(clojure.set/rename-keys {:canRequestAccess :can-request-access?
:canManageUsers :can-manage-users?
:canDeleteMessageForEveryone :can-delete-message-for-everyone?
:canJoin :can-join?
:requestedToJoinAt :requested-to-join-at
:isMember :is-member?})
(update :members walk/stringify-keys)
(update :chats <-chats-rpc)
(update :categories <-categories-rpc)))
@ -125,67 +126,67 @@
(fx/defn import-community
{:events [::import]}
[cofx community-key]
{::json-rpc/call [{:method "wakuext_importCommunity"
:params [community-key]
{::json-rpc/call [{:method "wakuext_importCommunity"
:params [community-key]
:js-response true
:on-success #(re-frame/dispatch [::community-imported %])
:on-error #(do
(log/error "failed to import community" %)
(re-frame/dispatch [::failed-to-import %]))}]})
:on-success #(re-frame/dispatch [::community-imported %])
:on-error #(do
(log/error "failed to import community" %)
(re-frame/dispatch [::failed-to-import %]))}]})
(fx/defn join
{:events [:communities/join]}
[cofx community-id]
{::json-rpc/call [{:method "wakuext_joinCommunity"
:params [community-id]
{::json-rpc/call [{:method "wakuext_joinCommunity"
:params [community-id]
:js-response true
:on-success #(re-frame/dispatch [::joined %])
:on-error #(do
(log/error "failed to join community" community-id %)
(re-frame/dispatch [::failed-to-join %]))}]})
:on-success #(re-frame/dispatch [::joined %])
:on-error #(do
(log/error "failed to join community" community-id %)
(re-frame/dispatch [::failed-to-join %]))}]})
(fx/defn request-to-join
{:events [::request-to-join]}
[cofx community-id]
{::json-rpc/call [{:method "wakuext_requestToJoinCommunity"
:params [{:communityId community-id}]
{::json-rpc/call [{:method "wakuext_requestToJoinCommunity"
:params [{:communityId community-id}]
:js-response true
:on-success #(re-frame/dispatch [::requested-to-join %])
:on-error #(do
(log/error "failed to request to join community" community-id %)
(re-frame/dispatch [::failed-to-request-to-join %]))}]})
:on-success #(re-frame/dispatch [::requested-to-join %])
:on-error #(do
(log/error "failed to request to join community" community-id %)
(re-frame/dispatch [::failed-to-request-to-join %]))}]})
(fx/defn leave
{:events [:communities/leave]}
[{:keys [db]} community-id]
(let [community-chat-ids (map #(str community-id %)
(keys (get-in db [:communities community-id :chats])))]
{:clear-message-notifications [community-chat-ids
(get-in db [:multiaccount :remote-push-notifications-enabled?])]
::json-rpc/call [{:method "wakuext_leaveCommunity"
:params [community-id]
:js-response true
:on-success #(re-frame/dispatch [::left %])
:on-error #(do
(log/error "failed to leave community" community-id %)
(re-frame/dispatch [::failed-to-leave %]))}]}))
{:clear-message-notifications [community-chat-ids
(get-in db [:multiaccount :remote-push-notifications-enabled?])]
::json-rpc/call [{:method "wakuext_leaveCommunity"
:params [community-id]
:js-response true
:on-success #(re-frame/dispatch [::left %])
:on-error #(do
(log/error "failed to leave community" community-id %)
(re-frame/dispatch [::failed-to-leave %]))}]}))
(fx/defn fetch [_]
{::json-rpc/call [{:method "wakuext_communities"
:params []
{::json-rpc/call [{:method "wakuext_communities"
:params []
:on-success #(re-frame/dispatch [::fetched %])
:on-error #(do
(log/error "failed to fetch communities" %)
(re-frame/dispatch [::failed-to-fetch %]))}]})
:on-error #(do
(log/error "failed to fetch communities" %)
(re-frame/dispatch [::failed-to-fetch %]))}]})
(fx/defn chat-created
{:events [::chat-created]}
[_ community-id user-pk]
{::json-rpc/call [{:method "wakuext_sendChatMessage"
:params [{:chatId user-pk
:text "Upgrade here to see an invitation to community"
:communityId community-id
:contentType constants/content-type-community}]
{::json-rpc/call [{:method "wakuext_sendChatMessage"
:params [{:chatId user-pk
:text "Upgrade here to see an invitation to community"
:communityId community-id
:contentType constants/content-type-community}]
:js-response true
:on-success
#(re-frame/dispatch [:transport/message-sent %])
@ -196,56 +197,56 @@
{:events [::invite-people-confirmation-pressed]}
[cofx user-pk contacts]
(let [community-id (fetch-community-id-input cofx)
pks (if (seq user-pk)
(conj contacts user-pk)
contacts)]
pks (if (seq user-pk)
(conj contacts user-pk)
contacts)]
(when (seq pks)
{::json-rpc/call [{:method "wakuext_inviteUsersToCommunity"
:params [{:communityId community-id
:users pks}]
{::json-rpc/call [{:method "wakuext_inviteUsersToCommunity"
:params [{:communityId community-id
:users pks}]
:js-response true
:on-success #(re-frame/dispatch [::people-invited %])
:on-error #(do
(log/error "failed to invite-user community" %)
(re-frame/dispatch [::failed-to-invite-people %]))}]})))
:on-success #(re-frame/dispatch [::people-invited %])
:on-error #(do
(log/error "failed to invite-user community" %)
(re-frame/dispatch [::failed-to-invite-people %]))}]})))
(fx/defn share-community
{:events [::share-community-confirmation-pressed]}
[cofx user-pk contacts]
(let [community-id (fetch-community-id-input cofx)
pks (if (seq user-pk)
(conj contacts user-pk)
contacts)]
pks (if (seq user-pk)
(conj contacts user-pk)
contacts)]
(when (seq pks)
{::json-rpc/call [{:method "wakuext_shareCommunity"
:params [{:communityId community-id
:users pks}]
{::json-rpc/call [{:method "wakuext_shareCommunity"
:params [{:communityId community-id
:users pks}]
:js-response true
:on-success #(re-frame/dispatch [::people-invited %])
:on-error #(do
(log/error "failed to invite-user community" %)
(re-frame/dispatch [::failed-to-share-community %]))}]})))
:on-success #(re-frame/dispatch [::people-invited %])
:on-error #(do
(log/error "failed to invite-user community" %)
(re-frame/dispatch [::failed-to-share-community %]))}]})))
(fx/defn create
{:events [::create-confirmation-pressed]}
[{:keys [db]}]
(let [{:keys [name description membership image]} (get db :communities/create)]
(let [params {:name name
(let [params {:name name
:description description
:membership membership
:color (rand-nth colors/chat-colors)
:image (string/replace-first (str image) #"file://" "")
:imageAx 0
:imageAy 0
:imageBx crop-size
:imageBy crop-size}]
:membership membership
:color (rand-nth colors/chat-colors)
:image (string/replace-first (str image) #"file://" "")
:imageAx 0
:imageAy 0
:imageBx crop-size
:imageBy crop-size}]
{::json-rpc/call [{:method "wakuext_createCommunity"
:params [params]
{::json-rpc/call [{:method "wakuext_createCommunity"
:params [params]
:js-response true
:on-success #(re-frame/dispatch [::community-created %])
:on-error #(do
(log/error "failed to create community" %)
(re-frame/dispatch [::failed-to-create-community %]))}]})))
:on-success #(re-frame/dispatch [::community-created %])
:on-error #(do
(log/error "failed to create community" %)
(re-frame/dispatch [::failed-to-create-community %]))}]})))
(fx/defn edit
{:events [::edit-confirmation-pressed]}
@ -253,15 +254,15 @@
(let [{:keys [id name description membership new-image color]} (get db :communities/create)]
{::json-rpc/call [{:method "wakuext_editCommunity"
:params [{:communityID id
:name name
:name name
:description description
:color color
:image (string/replace-first (str new-image) #"file://" "")
:imageAx 0
:imageAy 0
:imageBx crop-size
:imageBy crop-size
:membership membership}]
:color color
:image (string/replace-first (str new-image) #"file://" "")
:imageAx 0
:imageAy 0
:imageBx crop-size
:imageBy crop-size
:membership membership}]
:on-success #(re-frame/dispatch [::community-edited %])
:on-error #(do
(log/error "failed to edit community" %)
@ -272,18 +273,18 @@
[{:keys [db] :as cofx}]
(let [community-id (fetch-community-id-input cofx)
{:keys [name description color emoji]} (get db :communities/create-channel)]
{::json-rpc/call [{:method "wakuext_createCommunityChat"
:params [community-id
{:identity {:display_name name
:description description
:color color
:emoji emoji}
:permissions {:access constants/community-channel-access-no-membership}}]
{::json-rpc/call [{:method "wakuext_createCommunityChat"
:params [community-id
{:identity {:display_name name
:description description
:color color
:emoji emoji}
:permissions {:access constants/community-channel-access-no-membership}}]
:js-response true
:on-success #(re-frame/dispatch [::community-channel-created %])
:on-error #(do
(log/error "failed to create community channel" %)
(re-frame/dispatch [::failed-to-create-community-channel %]))}]}))
:on-success #(re-frame/dispatch [::community-channel-created %])
:on-error #(do
(log/error "failed to create community channel" %)
(re-frame/dispatch [::failed-to-create-community-channel %]))}]}))
(def community-chat-id-length 68)
@ -295,21 +296,21 @@
[{:keys [db] :as cofx}]
(let [{:keys [name description color community-id emoji edit-channel-id category-id position]}
(get db :communities/create-channel)]
{::json-rpc/call [{:method "wakuext_editCommunityChat"
:params [community-id
edit-channel-id
{:identity {:display_name name
:description description
:color color
:emoji emoji}
:category_id category-id
:position position
:permissions {:access constants/community-channel-access-no-membership}}]
{::json-rpc/call [{:method "wakuext_editCommunityChat"
:params [community-id
edit-channel-id
{:identity {:display_name name
:description description
:color color
:emoji emoji}
:category_id category-id
:position position
:permissions {:access constants/community-channel-access-no-membership}}]
:js-response true
:on-success #(re-frame/dispatch [::community-channel-edited %])
:on-error #(do
(log/error "failed to edit community channel" %)
(re-frame/dispatch [::failed-to-edit-community-channel %]))}]}))
:on-success #(re-frame/dispatch [::community-channel-edited %])
:on-error #(do
(log/error "failed to edit community channel" %)
(re-frame/dispatch [::failed-to-edit-community-channel %]))}]}))
(defn require-membership? [permissions]
(not= constants/community-no-membership-access (:access permissions)))
@ -461,12 +462,12 @@
(fx/defn member-ban
{:events [::member-ban]}
[cofx community-id public-key]
{::json-rpc/call [{:method "wakuext_banUserFromCommunity"
:params [{:communityId community-id
:user public-key}]
{::json-rpc/call [{:method "wakuext_banUserFromCommunity"
:params [{:communityId community-id
:user public-key}]
:js-response true
:on-success #(re-frame/dispatch [::member-banned %])
:on-error #(log/error "failed to ban user from community" community-id public-key %)}]})
:on-success #(re-frame/dispatch [::member-banned %])
:on-error #(log/error "failed to ban user from community" community-id public-key %)}]})
(fx/defn member-kicked
{:events [::member-kicked]}
@ -478,11 +479,11 @@
(fx/defn member-kick
{:events [::member-kick]}
[cofx community-id public-key]
{::json-rpc/call [{:method "wakuext_removeUserFromCommunity"
:params [community-id public-key]
{::json-rpc/call [{:method "wakuext_removeUserFromCommunity"
:params [community-id public-key]
:js-response true
:on-success #(re-frame/dispatch [::member-kicked %])
:on-error #(log/error "failed to remove user from community" community-id public-key %)}]})
:on-success #(re-frame/dispatch [::member-kicked %])
:on-error #(log/error "failed to remove user from community" community-id public-key %)}]})
(fx/defn delete-community
{:events [::delete-community]}
@ -522,88 +523,88 @@
(fx/defn accept-request-to-join-pressed
{:events [:communities.ui/accept-request-to-join-pressed]}
[cofx community-id request-id]
{::json-rpc/call [{:method "wakuext_acceptRequestToJoinCommunity"
:params [{:id request-id}]
{::json-rpc/call [{:method "wakuext_acceptRequestToJoinCommunity"
:params [{:id request-id}]
:js-response true
:on-success #(re-frame/dispatch [::request-to-join-accepted community-id request-id %])
:on-error #(log/error "failed to accept requests-to-join" community-id request-id %)}]})
:on-success #(re-frame/dispatch [::request-to-join-accepted community-id request-id %])
:on-error #(log/error "failed to accept requests-to-join" community-id request-id %)}]})
(fx/defn decline-request-to-join-pressed
{:events [:communities.ui/decline-request-to-join-pressed]}
[cofx community-id request-id]
{::json-rpc/call [{:method "wakuext_declineRequestToJoinCommunity"
:params [{:id request-id}]
{::json-rpc/call [{:method "wakuext_declineRequestToJoinCommunity"
:params [{:id request-id}]
:js-response true
:on-success #(re-frame/dispatch [::request-to-join-declined community-id request-id %])
:on-error #(log/error "failed to decline requests-to-join" community-id request-id)}]})
:on-success #(re-frame/dispatch [::request-to-join-declined community-id request-id %])
:on-error #(log/error "failed to decline requests-to-join" community-id request-id)}]})
(fx/defn switch-communities-enabled
{:events [:multiaccounts.ui/switch-communities-enabled]}
[{:keys [db]} enabled?]
{::async-storage/set! {:communities-enabled? enabled?}
:db (assoc db :communities/enabled? enabled?)})
:db (assoc db :communities/enabled? enabled?)})
(fx/defn create-category
{:events [::create-category-confirmation-pressed]}
[_ community-id category-title chat-ids]
{::json-rpc/call [{:method "wakuext_createCommunityCategory"
:params [{:communityId community-id
:categoryName category-title
:chatIds (map #(string/replace % community-id "") chat-ids)}]
{::json-rpc/call [{:method "wakuext_createCommunityCategory"
:params [{:communityId community-id
:categoryName category-title
:chatIds (map #(string/replace % community-id "") chat-ids)}]
:js-response true
:on-success #(do
(re-frame/dispatch [:navigate-back])
(re-frame/dispatch [:sanitize-messages-and-process-response %]))
:on-error #(log/error "failed to create community category" %)}]})
:on-success #(do
(re-frame/dispatch [:navigate-back])
(re-frame/dispatch [:sanitize-messages-and-process-response %]))
:on-error #(log/error "failed to create community category" %)}]})
(fx/defn remove-chat-from-category
{:events [:remove-chat-from-community-category]}
[{:keys [db]} community-id id categoryID]
(let [category (get-in db [:communities community-id :categories categoryID])
(let [category (get-in db [:communities community-id :categories categoryID])
category-chats (map :id (filter #(and (= (:categoryID %) categoryID) (not= id (:id %)))
(vals (get-in db [:communities community-id :chats]))))]
{::json-rpc/call [{:method "wakuext_editCommunityCategory"
:params [{:communityId community-id
:categoryId categoryID
:categoryName (:name category)
:chatIds category-chats}]
{::json-rpc/call [{:method "wakuext_editCommunityCategory"
:params [{:communityId community-id
:categoryId categoryID
:categoryName (:name category)
:chatIds category-chats}]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to remove chat from community" %)}]}))
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to remove chat from community" %)}]}))
(fx/defn delete-community-chat
{:events [:delete-community-chat]}
[_ community-id chat-id]
{::json-rpc/call [{:method "wakuext_deleteCommunityChat"
:params [community-id chat-id]
{::json-rpc/call [{:method "wakuext_deleteCommunityChat"
:params [community-id chat-id]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to delete community chat" %)}]})
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to delete community chat" %)}]})
(fx/defn delete-category
{:events [:delete-community-category]}
[_ community-id category-id]
{::json-rpc/call [{:method "wakuext_deleteCommunityCategory"
:params [{:communityId community-id
:categoryId category-id}]
{::json-rpc/call [{:method "wakuext_deleteCommunityCategory"
:params [{:communityId community-id
:categoryId category-id}]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to delete community category" %)}]})
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to delete community category" %)}]})
(fx/defn change-category
{:events [::change-category-confirmation-pressed]}
[cofx community-id category-id {:keys [id position categoryID]}]
(if (not (string/blank? category-id))
{::json-rpc/call [{:method "wakuext_reorderCommunityChat"
:params [{:communityId community-id
:categoryId category-id
:chatId id
:position position}]
{::json-rpc/call [{:method "wakuext_reorderCommunityChat"
:params [{:communityId community-id
:categoryId category-id
:chatId id
:position position}]
:js-response true
:on-success #(do
(re-frame/dispatch [:navigate-back])
(re-frame/dispatch [:sanitize-messages-and-process-response %]))
:on-error #(log/error "failed to change community category" %)}]}
:on-success #(do
(re-frame/dispatch [:navigate-back])
(re-frame/dispatch [:sanitize-messages-and-process-response %]))
:on-error #(log/error "failed to change community category" %)}]}
(fx/merge cofx
(navigation/navigate-back)
(remove-chat-from-category community-id id categoryID))))
@ -611,22 +612,22 @@
(fx/defn reorder-category-chat
{:events [::reorder-community-category-chat]}
[_ community-id category-id chat-id new-position]
{::json-rpc/call [{:method "wakuext_reorderCommunityChat"
:params [{:communityId community-id
:categoryId category-id
:chatId chat-id
:position new-position}]
{::json-rpc/call [{:method "wakuext_reorderCommunityChat"
:params [{:communityId community-id
:categoryId category-id
:chatId chat-id
:position new-position}]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to reorder community category chat" %)}]})
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to reorder community category chat" %)}]})
(fx/defn reorder-category
{:events [::reorder-community-category]}
[_ community-id category-id new-position]
{::json-rpc/call [{:method "wakuext_reorderCommunityCategories"
:params [{:communityId community-id
:categoryId category-id
:position new-position}]
{::json-rpc/call [{:method "wakuext_reorderCommunityCategories"
:params [{:communityId community-id
:categoryId category-id
:position new-position}]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/error "failed to reorder community category" %)}]})
@ -679,3 +680,38 @@
(fx/merge cofx
(navigation/pop-to-root-tab :shell-stack)
(navigation/navigate-to-nav2 :community community-id true)))
(fx/defn member-role-updated
{:events [:community.member/role-updated]}
[cofx response-js]
(fx/merge cofx
(bottom-sheet/hide-bottom-sheet)
(handle-response response-js)))
(fx/defn add-role-to-member
{:events [:community.member/add-role]}
[cofx community-id public-key role-id]
{::json-rpc/call [{:method "wakuext_addRoleToMember"
:params [{:communityId community-id
:user public-key
:role role-id}]
:on-success #(re-frame/dispatch [:community.member/role-updated %])
:on-error #(log/error "failed to add role to member"
{:error %
:community-id community-id
:public-key public-key
:role-id role-id})}]})
(fx/defn remove-role-from-member
{:events [:community.member/remove-role]}
[_ community-id public-key role-id]
{::json-rpc/call [{:method "wakuext_removeRoleFromMember"
:params [{:communityId community-id
:user public-key
:role role-id}]}
:on-success #(re-frame/dispatch [:community.member/role-updated %])
:on-error #(log/error "failed to remove role from member"
{:error %
:community-id community-id
:public-key public-key
:role-id role-id})]})

View File

@ -198,3 +198,7 @@
(def ^:const sticker-pack-status-owned 3)
(def ^:const delete-message-for-me-undo-time-limit-ms 4000)
(def ^:const community-member-role-all 1)
(def ^:const community-member-role-manage-users 2)
(def ^:const community-member-role-moderator 3)

View File

@ -16,7 +16,7 @@
(>evt [:bottom-sheet/hide])
(>evt event))
(defn member-sheet [first-name {:keys [public-key] :as member} community-id can-kick-users? can-manage-users?]
(defn member-sheet [first-name {:keys [public-key] :as member} community-id can-kick-users? can-manage-users? admin?]
[:<>
[quo/list-item
{:theme :accent
@ -26,7 +26,7 @@
:subtitle (i18n/label :t/view-profile)
:accessibility-label :view-chat-details-button
:chevron true
:on-press #(hide-sheet-and-dispatch [:chat.ui/show-profile public-key])}]
:on-press #(hide-sheet-and-dispatch [:chat.ui/show-profile public-key])}]
(when can-kick-users?
[:<>
[quo/separator {:style {:margin-vertical 8}}]
@ -39,13 +39,20 @@
[quo/list-item {:theme :negative
:icon :main-icons/cancel
:title (i18n/label :t/member-ban)
:on-press #(>evt [::communities/member-ban community-id public-key])}]])])
:on-press #(>evt [::communities/member-ban community-id public-key])}]])
(when admin?
[:<>
[quo/list-item {:theme :accent
:icon :main-icons/make-admin
:title (i18n/label :t/make-moderator)
:on-press #(>evt [:community.member/add-role community-id public-key constants/community-member-role-moderator])}]])])
(defn render-member [public-key _ _ {:keys [community-id
my-public-key
can-manage-users?
can-kick-users?]}]
(let [member (<sub [:contacts/contact-by-identity public-key])
can-kick-users?
admin?]}]
(let [member (<sub [:contacts/contact-by-identity public-key])
[first-name second-name] (<sub [:contacts/contact-two-names-by-identity public-key])]
[quo/list-item
{:title first-name
@ -58,7 +65,7 @@
[quo/button {:on-press
#(>evt [:bottom-sheet/show-sheet
{:content (fn []
[member-sheet first-name member community-id can-kick-users? can-manage-users?])}])
[member-sheet first-name member community-id can-kick-users? can-manage-users? admin?])}])
:type :icon
:theme :icon
:accessibility-label :menu-option}
@ -74,16 +81,16 @@
[quo/separator {:style {:margin-vertical 8}}]])
(defn requests-to-join [community-id]
(let [requests (<sub [:communities/requests-to-join-for-community community-id])
(let [requests (<sub [:communities/requests-to-join-for-community community-id])
requests-count (count requests)]
[:<>
[quo/list-item {:chevron true
[quo/list-item {:chevron true
:accessory
[react/view {:flex-direction :row}
(when (pos? requests-count)
[unviewed-indicator/unviewed-indicator requests-count])]
:on-press #(>evt [:navigate-to :community-requests-to-join {:community-id community-id}])
:title (i18n/label :t/membership-requests)}]
:on-press #(>evt [:navigate-to :community-requests-to-join {:community-id community-id}])
:title (i18n/label :t/membership-requests)}]
[quo/separator {:style {:margin-vertical 8}}]]))
(defn members []
@ -91,7 +98,8 @@
(fn []
(let [my-public-key (<sub [:multiaccount/public-key])
{:keys [permissions
can-manage-users?]} (<sub [:communities/community community-id])
can-manage-users?
admin]} (<sub [:communities/community community-id])
sorted-members (<sub [:communities/sorted-community-members
community-id])]
[:<>
@ -101,18 +109,19 @@
(when (and can-manage-users? (= constants/community-on-request-access (:access permissions)))
[requests-to-join community-id])
[rn/flat-list {:data (keys sorted-members)
:render-data {:community-id community-id
:my-public-key my-public-key
:can-kick-users? (and can-manage-users?
(not= (:access permissions)
constants/community-no-membership-access))
:can-manage-users? can-manage-users?}
:render-data {:community-id community-id
:my-public-key my-public-key
:can-kick-users? (and can-manage-users?
(not= (:access permissions)
constants/community-no-membership-access))
:can-manage-users? can-manage-users?
:admin? admin}
:key-fn identity
:render-fn render-member}]]))))
(defn members-container []
(reagent/create-class
{:display-name "community-members-view"
{:display-name "community-members-view"
:component-did-mount (fn []
(communities/fetch-requests-to-join! (get (<sub [:get-screen-params]) :community-id)))
:reagent-render members}))
:reagent-render members}))

View File

@ -416,7 +416,7 @@
(re-frame/dispatch [::models.pin-message/show-pin-limit-modal chat-id]))
(re-frame/dispatch [::models.pin-message/send-pin-message (assoc message :pinned (not pinned))]))))
(defn on-long-press-fn [on-long-press {:keys [pinned message-pin-enabled outgoing edit-enabled show-input? community?] :as message} content]
(defn on-long-press-fn [on-long-press {:keys [pinned message-pin-enabled outgoing edit-enabled show-input? community? can-delete-message-for-everyone?] :as message} content]
(on-long-press
(concat
(when (and outgoing edit-enabled)
@ -453,7 +453,7 @@
:label (i18n/label :t/delete-for-me)
:icon :i/delete
:id :delete-for-me}]
(when (and outgoing config/delete-message-enabled?)
(when (and (or outgoing can-delete-message-for-everyone?) config/delete-message-enabled?)
[{:type :danger
:on-press (fn []
(when pinned (pin-message message))

View File

@ -50,9 +50,9 @@
:height 12}]]])
(defn on-scroll [^js ev]
(let [y (-> ev .-nativeEvent .-contentOffset .-y)
layout-height (-> ev .-nativeEvent .-layoutMeasurement .-height)
threshold-height (* (/ layout-height 100) threshold-percentage-to-show-floating-scroll-down-button)
(let [y (-> ev .-nativeEvent .-contentOffset .-y)
layout-height (-> ev .-nativeEvent .-layoutMeasurement .-height)
threshold-height (* (/ layout-height 100) threshold-percentage-to-show-floating-scroll-down-button)
reached-threshold? (> y threshold-height)]
(when (not= reached-threshold? @show-floating-scroll-down-button)
(rn/configure-next (:ease-in-ease-out rn/layout-animation-presets))
@ -65,8 +65,8 @@
(defn list-footer [{:keys [chat-id] :as chat}]
(let [loading-messages? (<sub [:chats/loading-messages? chat-id])
no-messages? (<sub [:chats/chat-no-messages? chat-id])
all-loaded? (<sub [:chats/all-loaded? chat-id])]
no-messages? (<sub [:chats/chat-no-messages? chat-id])
all-loaded? (<sub [:chats/all-loaded? chat-id])]
[rn/view {:style (when platform/android? {:scaleY -1})}
(if (or loading-messages? (not chat-id) (not all-loaded?))
[messages-skeleton/messages-skeleton @messages-view-height]
@ -81,7 +81,7 @@
idx
_
{:keys [group-chat public? community? current-public-key
chat-id show-input? message-pin-enabled edit-enabled in-pinned-view?]}]
chat-id show-input? message-pin-enabled edit-enabled in-pinned-view? can-delete-message-for-everyone?]}]
[rn/view {:style (when (and platform/android? (not in-pinned-view?)) {:scaleY -1})}
(if (= type :datemark)
[message-datemark/chat-datemark (:value message)]
@ -97,13 +97,14 @@
:current-public-key current-public-key
:show-input? show-input?
:message-pin-enabled message-pin-enabled
:edit-enabled edit-enabled)]))])
:edit-enabled edit-enabled
:can-delete-message-for-everyone? can-delete-message-for-everyone?)]))])
(defn on-viewable-items-changed [^js e]
(when @messages-list-ref
(reset! state/first-not-visible-item
(when-let [^js last-visible-element (aget (.-viewableItems e) (dec (.-length ^js (.-viewableItems e))))]
(let [index (.-index last-visible-element)
(let [index (.-index last-visible-element)
;; Get first not visible element, if it's a datemark/gap
;; we might unnecessarely add messages on receiving as
;; they do not have a clock value, but most of the times
@ -123,25 +124,26 @@
(if platform/low-device? 700 200))))
(defn get-render-data [{:keys [group-chat chat-id public? community-id admins space-keeper show-input? edit-enabled in-pinned-view?]}]
(let [current-public-key (<sub [:multiaccount/public-key])
community (<sub [:communities/community community-id])
group-admin? (get admins current-public-key)
community-admin? (when community (community :admin))
(let [current-public-key (<sub [:multiaccount/public-key])
{:keys [can-delete-message-for-everyone?] :as community} (<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?))))]
{:group-chat group-chat
:public? public?
:community? (not (nil? community-id))
:current-public-key current-public-key
:space-keeper space-keeper
:chat-id chat-id
:show-input? show-input?
:message-pin-enabled message-pin-enabled
:edit-enabled edit-enabled
:in-pinned-view? in-pinned-view?}))
{:group-chat group-chat
:public? public?
:community? (not (nil? community-id))
:current-public-key current-public-key
:space-keeper space-keeper
:chat-id chat-id
:show-input? show-input?
:message-pin-enabled message-pin-enabled
:edit-enabled edit-enabled
:in-pinned-view? in-pinned-view?
:can-delete-message-for-everyone? can-delete-message-for-everyone?}))
(defn messages-view [{:keys [chat
bottom-space
@ -149,8 +151,8 @@
mutual-contact-requests-enabled?
show-input?]}]
(let [{:keys [group-chat chat-type chat-id public? community-id admins]} chat
messages (<sub [:chats/raw-chat-messages-stream chat-id])
one-to-one? (= chat-type constants/one-to-one-chat-type)
messages (<sub [:chats/raw-chat-messages-stream chat-id])
one-to-one? (= chat-type constants/one-to-one-chat-type)
contact-added? (when one-to-one? (<sub [:contacts/contact-added? chat-id]))
should-send-contact-request?
(and
@ -179,17 +181,17 @@
:render-fn render-fn
:on-viewable-items-changed on-viewable-items-changed
:on-end-reached list-on-end-reached
:on-scroll-to-index-failed identity ;;don't remove this
:on-scroll-to-index-failed identity ;;don't remove this
:content-container-style {:padding-top (+ bottom-space 16)
:padding-bottom 16}
:scroll-indicator-insets {:top bottom-space} ;;ios only
:scroll-indicator-insets {:top bottom-space} ;;ios only
:keyboard-dismiss-mode :interactive
:keyboard-should-persist-taps :handled
:onMomentumScrollBegin state/start-scrolling
:onMomentumScrollEnd state/stop-scrolling
:scrollEventThrottle 16
:on-scroll on-scroll
;;TODO https://github.com/facebook/react-native/issues/30034
;;TODO https://github.com/facebook/react-native/issues/30034
:inverted (when platform/ios? true)
:style (when platform/android? {:scaleY -1})
:on-layout on-messages-view-layout})]

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.115.2",
"commit-sha1": "9227c631c30a88548cf04bed3b32938ef56f71aa",
"src-sha256": "1rkfiy9ka7qkka1a08mzs27f358dfvwgjjkcjd68207snis536iz"
"version": "v0.115.5",
"commit-sha1": "684e9654de4800df619ce593b5d331ebea9ed1a8",
"src-sha256": "0ci1s3w5jnf6sz2b6hn30gy14hp142gic006r6c3g5ln8y19wdbi"
}

View File

@ -860,6 +860,7 @@
"main-wallet": "Main Wallet",
"mainnet-network": "Main network",
"make-admin": "Make admin",
"make-moderator": "Make moderator",
"manage-keys-and-storage": "Manage keys and storage",
"mark-as-read": "Mark as read",
"mark-all-read": "Mark all read",