fix: rewire legacy community share button to send invites (#19622)
This commit is contained in:
parent
8df72d0c29
commit
82a8f9f44d
|
@ -1,16 +1,15 @@
|
||||||
(ns legacy.status-im.ui.screens.communities.invite
|
(ns legacy.status-im.ui.screens.communities.invite
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[legacy.status-im.communities.core :as communities]
|
|
||||||
[legacy.status-im.ui.components.chat-icon.screen :as chat-icon.screen]
|
[legacy.status-im.ui.components.chat-icon.screen :as chat-icon.screen]
|
||||||
[legacy.status-im.ui.components.core :as quo]
|
[legacy.status-im.ui.components.core :as quo]
|
||||||
[legacy.status-im.ui.components.list.item :as list.item]
|
[legacy.status-im.ui.components.list.item :as list.item]
|
||||||
[legacy.status-im.ui.components.toolbar :as toolbar]
|
[legacy.status-im.ui.components.toolbar :as toolbar]
|
||||||
[legacy.status-im.ui.components.topbar :as topbar]
|
[legacy.status-im.ui.components.topbar :as topbar]
|
||||||
|
[quo.theme]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[utils.debounce :as debounce]
|
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
@ -49,18 +48,35 @@
|
||||||
contacts-selected (reagent/atom #{})
|
contacts-selected (reagent/atom #{})
|
||||||
{:keys [invite?]} (rf/sub [:get-screen-params])]
|
{:keys [invite?]} (rf/sub [:get-screen-params])]
|
||||||
(fn []
|
(fn []
|
||||||
(let [contacts-data (rf/sub [:contacts/active])
|
(let [theme (quo.theme/use-theme)
|
||||||
{:keys [permissions
|
contacts-data (rf/sub [:contacts/active])
|
||||||
|
{community-id :id
|
||||||
|
:keys [permissions
|
||||||
can-manage-users?]}
|
can-manage-users?]}
|
||||||
(rf/sub [:communities/edited-community])
|
(rf/sub [:communities/edited-community])
|
||||||
selected @contacts-selected
|
selected @contacts-selected
|
||||||
|
selected-contacts-count (count selected)
|
||||||
contacts (map (fn [{:keys [public-key] :as contact}]
|
contacts (map (fn [{:keys [public-key] :as contact}]
|
||||||
(assoc contact :active (contains? selected public-key)))
|
(assoc contact :active (contains? selected public-key)))
|
||||||
contacts-data)
|
contacts-data)
|
||||||
;; no-membership communities can only be shared
|
;; no-membership communities can only be shared
|
||||||
can-invite? (and can-manage-users?
|
can-invite? (and can-manage-users?
|
||||||
invite?
|
invite?
|
||||||
(not= (:access permissions) constants/community-no-membership-access))]
|
(not= (:access permissions) constants/community-no-membership-access))
|
||||||
|
on-press-share-community (rn/use-callback
|
||||||
|
(fn []
|
||||||
|
(rf/dispatch [:communities/share-community-confirmation-pressed
|
||||||
|
selected community-id])
|
||||||
|
(rf/dispatch [:navigate-back])
|
||||||
|
(rf/dispatch [:toasts/upsert
|
||||||
|
{:type :positive
|
||||||
|
:theme theme
|
||||||
|
:text (if (= 1 selected-contacts-count)
|
||||||
|
(i18n/label :t/one-user-was-invited)
|
||||||
|
(i18n/label
|
||||||
|
:t/n-users-were-invited
|
||||||
|
{:count selected-contacts-count}))}]))
|
||||||
|
[community-id selected selected-contacts-count theme])]
|
||||||
[:<>
|
[:<>
|
||||||
[topbar/topbar
|
[topbar/topbar
|
||||||
{:title (i18n/label (if can-invite?
|
{:title (i18n/label (if can-invite?
|
||||||
|
@ -81,11 +97,8 @@
|
||||||
:center
|
:center
|
||||||
[quo/button
|
[quo/button
|
||||||
{:disabled (and (string/blank? @user-pk)
|
{:disabled (and (string/blank? @user-pk)
|
||||||
(zero? (count selected)))
|
(zero? selected-contacts-count))
|
||||||
:accessibility-label :share-community-link
|
:accessibility-label :share-community-link
|
||||||
:type :secondary
|
:type :secondary
|
||||||
:on-press #(debounce/throttle-and-dispatch
|
:on-press on-press-share-community}
|
||||||
[::communities/share-community-confirmation-pressed @user-pk
|
|
||||||
selected]
|
|
||||||
3000)}
|
|
||||||
(i18n/label (if can-invite? :t/invite :t/share))]}]]))))
|
(i18n/label (if can-invite? :t/invite :t/share))]}]]))))
|
||||||
|
|
Loading…
Reference in New Issue