Disable button when request is in flight
This commit is contained in:
parent
7de1f95054
commit
98deaa4459
|
@ -64,6 +64,7 @@
|
||||||
:canJoin :can-join?
|
:canJoin :can-join?
|
||||||
:requestedToJoinAt :requested-to-join-at
|
:requestedToJoinAt :requested-to-join-at
|
||||||
:isMember :is-member?
|
:isMember :is-member?
|
||||||
|
:outroMessage :outro-message
|
||||||
:adminSettings :admin-settings
|
:adminSettings :admin-settings
|
||||||
:tokenPermissions :token-permissions
|
:tokenPermissions :token-permissions
|
||||||
:communityTokensMetadata :tokens-metadata
|
:communityTokensMetadata :tokens-metadata
|
||||||
|
|
|
@ -195,41 +195,23 @@
|
||||||
:button-type :grey
|
:button-type :grey
|
||||||
:on-button-press open-permission-sheet))])]))
|
:on-button-press open-permission-sheet))])]))
|
||||||
|
|
||||||
(defn view
|
(defn selection-bottom-actions
|
||||||
[]
|
[id
|
||||||
(let [{id :community-id} (rf/sub [:get-screen-params])
|
{:keys [flag-share-all-addresses
|
||||||
{:keys [color joined] outro-message :outroMessage} (rf/sub [:communities/community id])
|
addresses-to-reveal
|
||||||
|
cancel-selection
|
||||||
highest-role (rf/sub [:communities/highest-role-for-selection id])
|
can-edit-addresses?
|
||||||
[unmodified-role _] (rn/use-state highest-role)
|
identical-choices?]}]
|
||||||
|
(let [color (rf/sub [:communities/community-color id])
|
||||||
can-edit-addresses? (rf/sub [:communities/can-edit-shared-addresses? id])
|
outro-message (rf/sub [:communities/community-outro-message id])
|
||||||
pending? (boolean (rf/sub [:communities/my-pending-request-to-join id]))
|
joined (rf/sub [:communities/community-joined id])
|
||||||
|
checking? (rf/sub [:communities/permissions-check-for-selection-checking? id])
|
||||||
wallet-accounts (rf/sub [:wallet/accounts-without-watched-accounts])
|
|
||||||
unmodified-addresses-to-reveal (rf/sub [:communities/addresses-to-reveal id])
|
|
||||||
[addresses-to-reveal set-addresses-to-reveal] (rn/use-state unmodified-addresses-to-reveal)
|
|
||||||
|
|
||||||
unmodified-flag-share-all-addresses (rf/sub [:communities/share-all-addresses? id])
|
|
||||||
[flag-share-all-addresses
|
|
||||||
set-flag-share-all-addresses] (rn/use-state unmodified-flag-share-all-addresses)
|
|
||||||
|
|
||||||
identical-choices? (and (= unmodified-addresses-to-reveal addresses-to-reveal)
|
|
||||||
(= unmodified-flag-share-all-addresses flag-share-all-addresses))
|
|
||||||
|
|
||||||
toggle-flag-share-all-addresses
|
|
||||||
(fn []
|
|
||||||
(let [new-value (not flag-share-all-addresses)]
|
|
||||||
(set-flag-share-all-addresses new-value)
|
|
||||||
(when new-value
|
|
||||||
(set-addresses-to-reveal (set (map :address wallet-accounts))))))
|
|
||||||
|
|
||||||
cancel-join-request
|
cancel-join-request
|
||||||
(rn/use-callback
|
(rn/use-callback
|
||||||
(fn []
|
(fn []
|
||||||
(rf/dispatch [:show-bottom-sheet
|
(rf/dispatch [:show-bottom-sheet
|
||||||
{:content (fn [] [cancel-join-request-drawer id])}])))
|
{:content (fn [] [cancel-join-request-drawer id])}])))
|
||||||
|
|
||||||
leave-community
|
leave-community
|
||||||
(rn/use-callback
|
(rn/use-callback
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -237,14 +219,6 @@
|
||||||
{:content (fn [] [leave-community-drawer id outro-message])}]))
|
{:content (fn [] [leave-community-drawer id outro-message])}]))
|
||||||
[outro-message])
|
[outro-message])
|
||||||
|
|
||||||
cancel-selection
|
|
||||||
(fn []
|
|
||||||
(rf/dispatch [:communities/check-permissions-to-join-community
|
|
||||||
id
|
|
||||||
unmodified-addresses-to-reveal
|
|
||||||
:based-on-client-selection])
|
|
||||||
(rf/dispatch [:hide-bottom-sheet]))
|
|
||||||
|
|
||||||
confirm-changes
|
confirm-changes
|
||||||
(fn []
|
(fn []
|
||||||
(if can-edit-addresses?
|
(if can-edit-addresses?
|
||||||
|
@ -263,7 +237,107 @@
|
||||||
(rf/dispatch [:hide-bottom-sheet]))}]))}])
|
(rf/dispatch [:hide-bottom-sheet]))}]))}])
|
||||||
(do
|
(do
|
||||||
(rf/dispatch [:communities/set-share-all-addresses id flag-share-all-addresses])
|
(rf/dispatch [:communities/set-share-all-addresses id flag-share-all-addresses])
|
||||||
(rf/dispatch [:communities/set-addresses-to-reveal id addresses-to-reveal]))))]
|
(rf/dispatch [:communities/set-addresses-to-reveal id addresses-to-reveal]))))
|
||||||
|
pending? (rf/sub [:communities/has-pending-request-to-join? id])
|
||||||
|
highest-role (rf/sub [:communities/highest-role-for-selection id])
|
||||||
|
[unmodified-role _] (rn/use-state highest-role)]
|
||||||
|
|
||||||
|
[quo/bottom-actions
|
||||||
|
(cond-> {:role (role-keyword highest-role)
|
||||||
|
:description (if highest-role
|
||||||
|
:top
|
||||||
|
:top-error)
|
||||||
|
:button-one-props {:customization-color color
|
||||||
|
:on-press confirm-changes
|
||||||
|
:disabled? (or checking?
|
||||||
|
(empty? addresses-to-reveal)
|
||||||
|
(not highest-role)
|
||||||
|
identical-choices?)}}
|
||||||
|
can-edit-addresses?
|
||||||
|
(->
|
||||||
|
(assoc :actions :one-action
|
||||||
|
:button-one-label (cond
|
||||||
|
(and pending? (not highest-role))
|
||||||
|
(i18n/label :t/cancel-request)
|
||||||
|
|
||||||
|
(and joined (not highest-role))
|
||||||
|
(i18n/label :t/leave-community)
|
||||||
|
|
||||||
|
:else
|
||||||
|
(i18n/label :t/confirm-changes))
|
||||||
|
:description-top-text (cond
|
||||||
|
(and pending? highest-role)
|
||||||
|
(i18n/label :t/eligible-to-join-as)
|
||||||
|
|
||||||
|
(and joined (= highest-role unmodified-role))
|
||||||
|
(i18n/label :t/you-are-a)
|
||||||
|
|
||||||
|
(and joined (not= highest-role unmodified-role))
|
||||||
|
(i18n/label :t/you-will-be-a))
|
||||||
|
:error-message (cond
|
||||||
|
(and pending? (not highest-role))
|
||||||
|
(i18n/label :t/community-join-requirements-not-met)
|
||||||
|
|
||||||
|
(and joined (not highest-role))
|
||||||
|
(i18n/label :t/membership-requirements-not-met)))
|
||||||
|
(update :button-one-props
|
||||||
|
merge
|
||||||
|
(cond (and pending? (not highest-role))
|
||||||
|
{:type :danger
|
||||||
|
:disabled? false
|
||||||
|
:on-press cancel-join-request}
|
||||||
|
|
||||||
|
(and joined (not highest-role))
|
||||||
|
{:type :danger
|
||||||
|
:disabled? false
|
||||||
|
:on-press leave-community})))
|
||||||
|
|
||||||
|
(not can-edit-addresses?)
|
||||||
|
(assoc :actions :two-actions
|
||||||
|
:button-one-label (i18n/label :t/confirm-changes)
|
||||||
|
:button-two-label (i18n/label :t/cancel)
|
||||||
|
:button-two-props {:type :grey
|
||||||
|
:on-press cancel-selection}
|
||||||
|
:error-message (cond
|
||||||
|
(empty? addresses-to-reveal)
|
||||||
|
(i18n/label :t/no-addresses-selected)
|
||||||
|
|
||||||
|
(not highest-role)
|
||||||
|
(i18n/label :t/addresses-dont-contain-tokens-needed))))]))
|
||||||
|
|
||||||
|
(defn view
|
||||||
|
[]
|
||||||
|
(let [{id :community-id} (rf/sub [:get-screen-params])
|
||||||
|
|
||||||
|
color (rf/sub [:communities/community-color id])
|
||||||
|
|
||||||
|
can-edit-addresses? (rf/sub [:communities/can-edit-shared-addresses? id])
|
||||||
|
|
||||||
|
wallet-accounts (rf/sub [:wallet/accounts-without-watched-accounts])
|
||||||
|
unmodified-addresses-to-reveal (rf/sub [:communities/addresses-to-reveal id])
|
||||||
|
[addresses-to-reveal set-addresses-to-reveal] (rn/use-state unmodified-addresses-to-reveal)
|
||||||
|
|
||||||
|
unmodified-flag-share-all-addresses (rf/sub [:communities/share-all-addresses? id])
|
||||||
|
[flag-share-all-addresses
|
||||||
|
set-flag-share-all-addresses] (rn/use-state unmodified-flag-share-all-addresses)
|
||||||
|
|
||||||
|
identical-choices? (and (= unmodified-addresses-to-reveal addresses-to-reveal)
|
||||||
|
(= unmodified-flag-share-all-addresses flag-share-all-addresses))
|
||||||
|
|
||||||
|
cancel-selection
|
||||||
|
(fn []
|
||||||
|
(rf/dispatch [:communities/check-permissions-to-join-community
|
||||||
|
id
|
||||||
|
unmodified-addresses-to-reveal
|
||||||
|
:based-on-client-selection])
|
||||||
|
(rf/dispatch [:hide-bottom-sheet]))
|
||||||
|
|
||||||
|
toggle-flag-share-all-addresses
|
||||||
|
(fn []
|
||||||
|
(let [new-value (not flag-share-all-addresses)]
|
||||||
|
(set-flag-share-all-addresses new-value)
|
||||||
|
(when new-value
|
||||||
|
(set-addresses-to-reveal (set (map :address wallet-accounts))))))]
|
||||||
|
|
||||||
(rn/use-mount
|
(rn/use-mount
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -274,7 +348,6 @@
|
||||||
(fn []
|
(fn []
|
||||||
(rf/dispatch [:communities/check-permissions-to-join-during-selection id addresses-to-reveal]))
|
(rf/dispatch [:communities/check-permissions-to-join-during-selection id addresses-to-reveal]))
|
||||||
[id addresses-to-reveal])
|
[id addresses-to-reveal])
|
||||||
|
|
||||||
[:<>
|
[:<>
|
||||||
[page-top
|
[page-top
|
||||||
{:community-id id
|
{:community-id id
|
||||||
|
@ -299,64 +372,14 @@
|
||||||
:key-fn :address
|
:key-fn :address
|
||||||
:data wallet-accounts}]
|
:data wallet-accounts}]
|
||||||
|
|
||||||
[quo/bottom-actions
|
[selection-bottom-actions id
|
||||||
(cond-> {:role (role-keyword highest-role)
|
{:flag-share-all-addresses
|
||||||
:description (if highest-role
|
flag-share-all-addresses
|
||||||
:top
|
:addresses-to-reveal
|
||||||
:top-error)
|
addresses-to-reveal
|
||||||
:button-one-props {:customization-color color
|
:cancel-selection
|
||||||
:on-press confirm-changes
|
cancel-selection
|
||||||
:disabled? (or (empty? addresses-to-reveal)
|
:can-edit-addresses?
|
||||||
(not highest-role)
|
can-edit-addresses?
|
||||||
identical-choices?)}}
|
:identical-choices?
|
||||||
can-edit-addresses?
|
identical-choices?}]]))
|
||||||
(->
|
|
||||||
(assoc :actions :one-action
|
|
||||||
:button-one-label (cond
|
|
||||||
(and pending? (not highest-role))
|
|
||||||
(i18n/label :t/cancel-request)
|
|
||||||
|
|
||||||
(and joined (not highest-role))
|
|
||||||
(i18n/label :t/leave-community)
|
|
||||||
|
|
||||||
:else
|
|
||||||
(i18n/label :t/confirm-changes))
|
|
||||||
:description-top-text (cond
|
|
||||||
(and pending? highest-role)
|
|
||||||
(i18n/label :t/eligible-to-join-as)
|
|
||||||
|
|
||||||
(and joined (= highest-role unmodified-role))
|
|
||||||
(i18n/label :t/you-are-a)
|
|
||||||
|
|
||||||
(and joined (not= highest-role unmodified-role))
|
|
||||||
(i18n/label :t/you-will-be-a))
|
|
||||||
:error-message (cond
|
|
||||||
(and pending? (not highest-role))
|
|
||||||
(i18n/label :t/community-join-requirements-not-met)
|
|
||||||
|
|
||||||
(and joined (not highest-role))
|
|
||||||
(i18n/label :t/membership-requirements-not-met)))
|
|
||||||
(update :button-one-props
|
|
||||||
merge
|
|
||||||
(cond (and pending? (not highest-role))
|
|
||||||
{:type :danger
|
|
||||||
:disabled? false
|
|
||||||
:on-press cancel-join-request}
|
|
||||||
|
|
||||||
(and joined (not highest-role))
|
|
||||||
{:type :danger
|
|
||||||
:disabled? false
|
|
||||||
:on-press leave-community})))
|
|
||||||
|
|
||||||
(not can-edit-addresses?)
|
|
||||||
(assoc :actions :two-actions
|
|
||||||
:button-one-label (i18n/label :t/confirm-changes)
|
|
||||||
:button-two-label (i18n/label :t/cancel)
|
|
||||||
:button-two-props {:type :grey
|
|
||||||
:on-press cancel-selection}
|
|
||||||
:error-message (cond
|
|
||||||
(empty? addresses-to-reveal)
|
|
||||||
(i18n/label :t/no-addresses-selected)
|
|
||||||
|
|
||||||
(not highest-role)
|
|
||||||
(i18n/label :t/addresses-dont-contain-tokens-needed))))]]))
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(def commmunity-keys-renamed
|
(def community-keys-renamed
|
||||||
{:requestedAccessAt :requested-access-at
|
{:requestedAccessAt :requested-access-at
|
||||||
:fileSize :file-size
|
:fileSize :file-size
|
||||||
:communityTokensMetadata :community-tokens-metadata
|
:communityTokensMetadata :community-tokens-metadata
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
[k]
|
[k]
|
||||||
(let [s (name k)
|
(let [s (name k)
|
||||||
starts-with-digit? (re-matches #"^\d.*" s)
|
starts-with-digit? (re-matches #"^\d.*" s)
|
||||||
existing-rename (k commmunity-keys-renamed)]
|
existing-rename (k community-keys-renamed)]
|
||||||
(cond starts-with-digit? s
|
(cond starts-with-digit? s
|
||||||
existing-rename existing-rename
|
existing-rename existing-rename
|
||||||
:else (keyword s))))
|
:else (keyword s))))
|
||||||
|
|
|
@ -32,21 +32,38 @@
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/community-chats
|
:communities/community-chats
|
||||||
:<- [:communities]
|
(fn [[_ community-id]]
|
||||||
(fn [communities [_ id]]
|
[(re-frame/subscribe [:communities/community community-id])])
|
||||||
(get-in communities [id :chats])))
|
(fn [[{:keys [chats]}] _]
|
||||||
|
chats))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/community-color
|
:communities/community-color
|
||||||
:<- [:communities]
|
(fn [[_ community-id]]
|
||||||
(fn [communities [_ id]]
|
[(re-frame/subscribe [:communities/community community-id])])
|
||||||
(get-in communities [id :color])))
|
(fn [[{:keys [color]}] _]
|
||||||
|
color))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:communities/community-outro-message
|
||||||
|
(fn [[_ community-id]]
|
||||||
|
[(re-frame/subscribe [:communities/community community-id])])
|
||||||
|
(fn [[{:keys [outro-message]}] _]
|
||||||
|
outro-message))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:communities/community-joined
|
||||||
|
(fn [[_ community-id]]
|
||||||
|
[(re-frame/subscribe [:communities/community community-id])])
|
||||||
|
(fn [[{:keys [joined]}] _]
|
||||||
|
joined))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/community-members
|
:communities/community-members
|
||||||
:<- [:communities]
|
(fn [[_ community-id]]
|
||||||
(fn [communities [_ id]]
|
[(re-frame/subscribe [:communities/community community-id])])
|
||||||
(get-in communities [id :members])))
|
(fn [[{:keys [members]}] _]
|
||||||
|
members))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/current-community-members
|
:communities/current-community-members
|
||||||
|
@ -160,6 +177,13 @@
|
||||||
(fn [requests [_ community-id]]
|
(fn [requests [_ community-id]]
|
||||||
(:id (get requests community-id))))
|
(:id (get requests community-id))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:communities/has-pending-request-to-join?
|
||||||
|
(fn [[_ community-id]]
|
||||||
|
(re-frame/subscribe [:communities/my-pending-request-to-join community-id]))
|
||||||
|
(fn [request]
|
||||||
|
(boolean request)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/edited-community
|
:communities/edited-community
|
||||||
:<- [:communities]
|
:<- [:communities]
|
||||||
|
@ -329,6 +353,7 @@
|
||||||
(fn [permissions [_ id]]
|
(fn [permissions [_ id]]
|
||||||
(get permissions id)))
|
(get permissions id)))
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/checking-permissions-all-by-id
|
:communities/checking-permissions-all-by-id
|
||||||
:<- [:communities/permissions-check-all]
|
:<- [:communities/permissions-check-all]
|
||||||
|
|
|
@ -345,7 +345,7 @@
|
||||||
:members {"0x04" {"roles" [1]}}}}
|
:members {"0x04" {"roles" [1]}}}}
|
||||||
:members {"0x04" {"roles" [1]}}
|
:members {"0x04" {"roles" [1]}}
|
||||||
:can-request-access? false
|
:can-request-access? false
|
||||||
:outroMessage "bla"
|
:outro-message "bla"
|
||||||
:verified false}]
|
:verified false}]
|
||||||
(swap! rf-db/app-db assoc-in [:communities community-id] community)
|
(swap! rf-db/app-db assoc-in [:communities community-id] community)
|
||||||
(swap! rf-db/app-db assoc-in [:communities/permissions-check community-id] checks)
|
(swap! rf-db/app-db assoc-in [:communities/permissions-check community-id] checks)
|
||||||
|
@ -439,7 +439,7 @@
|
||||||
:token-images {"ETH" token-image-eth}
|
:token-images {"ETH" token-image-eth}
|
||||||
:name "Community super name"
|
:name "Community super name"
|
||||||
:can-request-access? false
|
:can-request-access? false
|
||||||
:outroMessage "bla"
|
:outro-message "bla"
|
||||||
:verified false}]
|
:verified false}]
|
||||||
(swap! rf-db/app-db assoc-in [:communities community-id] community)
|
(swap! rf-db/app-db assoc-in [:communities community-id] community)
|
||||||
(swap! rf-db/app-db assoc-in [:communities/permissions-check-all community-id] checks)
|
(swap! rf-db/app-db assoc-in [:communities/permissions-check-all community-id] checks)
|
||||||
|
@ -475,7 +475,7 @@
|
||||||
:token-images {"ETH" token-image-eth}
|
:token-images {"ETH" token-image-eth}
|
||||||
:name "Community super name"
|
:name "Community super name"
|
||||||
:can-request-access? false
|
:can-request-access? false
|
||||||
:outroMessage "bla"
|
:outro-message "bla"
|
||||||
:verified false}]
|
:verified false}]
|
||||||
(swap! rf-db/app-db assoc-in [:communities community-id] community)
|
(swap! rf-db/app-db assoc-in [:communities community-id] community)
|
||||||
(swap! rf-db/app-db assoc-in [:communities/permissions-check-all community-id] checks)
|
(swap! rf-db/app-db assoc-in [:communities/permissions-check-all community-id] checks)
|
||||||
|
|
|
@ -40,6 +40,13 @@
|
||||||
(fn [permissions [_ id]]
|
(fn [permissions [_ id]]
|
||||||
(get permissions id)))
|
(get permissions id)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:communities/permissions-check-for-selection-checking?
|
||||||
|
(fn [[_ community-id]]
|
||||||
|
(re-frame/subscribe [:communities/permissions-check-for-selection community-id]))
|
||||||
|
(fn [check]
|
||||||
|
(:checking? check)))
|
||||||
|
|
||||||
(re-frame/reg-sub :communities/highest-role-for-selection
|
(re-frame/reg-sub :communities/highest-role-for-selection
|
||||||
(fn [[_ community-id]]
|
(fn [[_ community-id]]
|
||||||
[(re-frame/subscribe [:communities/permissions-check-for-selection community-id])])
|
[(re-frame/subscribe [:communities/permissions-check-for-selection community-id])])
|
||||||
|
|
Loading…
Reference in New Issue