Skip to content

Commit

Permalink
🎊 Consider all statues in checking WG lock state (Joystream#3823)
Browse files Browse the repository at this point in the history
* Consider all statues in checking WG lock state

* Correct on the logic when worker is not leaving role
  • Loading branch information
WRadoslaw authored Nov 29, 2022
1 parent 2644a32 commit e67eb63
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/ui/src/accounts/hooks/useGroupLocks/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ export const useIsWGLockRecoverable = (hasWGLock: boolean, stakingAccount: strin
})
const workerId = workerData?.workers[0]?.id
const { unstakingPeriodEnd } = useWorkerUnstakingPeriodEnd(workerId)
const status = applications[0]?.status

if (!hasWGLock) return

if (applications[0]?.status === 'ApplicationStatusPending') {
return true
}

if (applications[0]?.status === 'ApplicationStatusAccepted') {
if (status === 'ApplicationStatusAccepted') {
if (unstakingPeriodEnd) {
return Date.parse(unstakingPeriodEnd) > Date.now()
}
return true
return false
}

return false
return !!(status && status !== 'ApplicationStatusWithdrawn')
}

export const useIsCandidateLockRecoverable = (hasCandidateLock: boolean, stakingAccount: string) => {
Expand Down

0 comments on commit e67eb63

Please sign in to comment.