Skip to content

Commit

Permalink
loader on undelegating and unlocking buttons (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Sep 18, 2024
1 parent 93de301 commit e7fe7f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/LocksCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ export const LocksCard = () => {
className="mb-2 mt-4 w-full"
onClick={onUnlockClick}
disabled={isUnlockingLoading}
loading={isUnlockingLoading}
>
Unlock
{isUnlockingLoading ? 'Unlocking...' : 'Unlock'}
</Button>
)}
<ContentReveal hidden={freeLocks.length == 0}>
Expand Down
11 changes: 7 additions & 4 deletions src/components/MyDelegations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export const MyDelegations = () => {
(delegate: string) => {
if (!api || !selectedAccount || !delegations) return

const tracks = delegations[delegate].map((d) => d.trackId)

setDelegatesLoading((prev) => [...prev, delegate])

const tracks = delegations[delegate].map((d) => d.trackId)

// @ts-expect-error we can't strongly type this
let tx: Transaction<undefined, unknown, unknown, undefined>

Expand All @@ -72,6 +72,7 @@ export const MyDelegations = () => {
refreshLocks()
},
})

tx.signSubmitAndWatch(selectedAccount.polkadotSigner).subscribe(
subscriptionCallback,
)
Expand Down Expand Up @@ -100,6 +101,7 @@ export const MyDelegations = () => {
Object.entries(delegationsByDelegateConvictionAmount).map(
([delegateAddress, amountConvictionMap]) => {
const knownDelegate = getDelegateByAddress(delegateAddress)
const isUndelegating = delegateLoading.includes(delegateAddress)

return (
<Card
Expand Down Expand Up @@ -132,9 +134,10 @@ export const MyDelegations = () => {
className="w-a bottom-0 mb-2 mt-4"
variant={'outline'}
onClick={() => onUndelegate(delegateAddress)}
disabled={delegateLoading.includes(delegateAddress)}
disabled={isUndelegating}
loading={isUndelegating}
>
Undelegate
{isUndelegating ? 'Undelegating...' : 'Undelegate'}
</Button>
</>
</Card>
Expand Down

0 comments on commit e7fe7f5

Please sign in to comment.