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,41 +237,10 @@
|
||||||
(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])
|
||||||
(rn/use-mount
|
highest-role (rf/sub [:communities/highest-role-for-selection id])
|
||||||
(fn []
|
[unmodified-role _] (rn/use-state highest-role)]
|
||||||
(when-not flag-share-all-addresses
|
|
||||||
(rf/dispatch [:communities/get-permissioned-balances id]))))
|
|
||||||
|
|
||||||
(rn/use-effect
|
|
||||||
(fn []
|
|
||||||
(rf/dispatch [:communities/check-permissions-to-join-during-selection id addresses-to-reveal]))
|
|
||||||
[id addresses-to-reveal])
|
|
||||||
|
|
||||||
[:<>
|
|
||||||
[page-top
|
|
||||||
{:community-id id
|
|
||||||
:identical-choices? identical-choices?
|
|
||||||
:can-edit-addresses? can-edit-addresses?}]
|
|
||||||
|
|
||||||
[gesture/flat-list
|
|
||||||
{:render-fn account-item
|
|
||||||
:render-data [addresses-to-reveal
|
|
||||||
set-addresses-to-reveal
|
|
||||||
id
|
|
||||||
color
|
|
||||||
flag-share-all-addresses]
|
|
||||||
:header [quo/page-setting
|
|
||||||
{:checked? flag-share-all-addresses
|
|
||||||
:customization-color color
|
|
||||||
:on-change toggle-flag-share-all-addresses
|
|
||||||
:setting-text (i18n/label
|
|
||||||
:t/share-all-current-and-future-addresses)
|
|
||||||
:container-style {:margin-bottom 16}}]
|
|
||||||
:content-container-style {:padding-horizontal 20}
|
|
||||||
:key-fn :address
|
|
||||||
:data wallet-accounts}]
|
|
||||||
|
|
||||||
[quo/bottom-actions
|
[quo/bottom-actions
|
||||||
(cond-> {:role (role-keyword highest-role)
|
(cond-> {:role (role-keyword highest-role)
|
||||||
|
@ -306,7 +249,8 @@
|
||||||
:top-error)
|
:top-error)
|
||||||
:button-one-props {:customization-color color
|
:button-one-props {:customization-color color
|
||||||
:on-press confirm-changes
|
:on-press confirm-changes
|
||||||
:disabled? (or (empty? addresses-to-reveal)
|
:disabled? (or checking?
|
||||||
|
(empty? addresses-to-reveal)
|
||||||
(not highest-role)
|
(not highest-role)
|
||||||
identical-choices?)}}
|
identical-choices?)}}
|
||||||
can-edit-addresses?
|
can-edit-addresses?
|
||||||
|
@ -359,4 +303,83 @@
|
||||||
(i18n/label :t/no-addresses-selected)
|
(i18n/label :t/no-addresses-selected)
|
||||||
|
|
||||||
(not highest-role)
|
(not highest-role)
|
||||||
(i18n/label :t/addresses-dont-contain-tokens-needed))))]]))
|
(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
|
||||||
|
(fn []
|
||||||
|
(when-not flag-share-all-addresses
|
||||||
|
(rf/dispatch [:communities/get-permissioned-balances id]))))
|
||||||
|
|
||||||
|
(rn/use-effect
|
||||||
|
(fn []
|
||||||
|
(rf/dispatch [:communities/check-permissions-to-join-during-selection id addresses-to-reveal]))
|
||||||
|
[id addresses-to-reveal])
|
||||||
|
[:<>
|
||||||
|
[page-top
|
||||||
|
{:community-id id
|
||||||
|
:identical-choices? identical-choices?
|
||||||
|
:can-edit-addresses? can-edit-addresses?}]
|
||||||
|
|
||||||
|
[gesture/flat-list
|
||||||
|
{:render-fn account-item
|
||||||
|
:render-data [addresses-to-reveal
|
||||||
|
set-addresses-to-reveal
|
||||||
|
id
|
||||||
|
color
|
||||||
|
flag-share-all-addresses]
|
||||||
|
:header [quo/page-setting
|
||||||
|
{:checked? flag-share-all-addresses
|
||||||
|
:customization-color color
|
||||||
|
:on-change toggle-flag-share-all-addresses
|
||||||
|
:setting-text (i18n/label
|
||||||
|
:t/share-all-current-and-future-addresses)
|
||||||
|
:container-style {:margin-bottom 16}}]
|
||||||
|
:content-container-style {:padding-horizontal 20}
|
||||||
|
:key-fn :address
|
||||||
|
:data wallet-accounts}]
|
||||||
|
|
||||||
|
[selection-bottom-actions id
|
||||||
|
{:flag-share-all-addresses
|
||||||
|
flag-share-all-addresses
|
||||||
|
:addresses-to-reveal
|
||||||
|
addresses-to-reveal
|
||||||
|
:cancel-selection
|
||||||
|
cancel-selection
|
||||||
|
:can-edit-addresses?
|
||||||
|
can-edit-addresses?
|
||||||
|
:identical-choices?
|
||||||
|
identical-choices?}]]))
|
||||||
|
|
|
@ -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