forked from Joystream/atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import { useRef } from 'react' | ||
|
||
// import { useRef } from 'react' | ||
import { FullCreatorTokenFragment } from '@/api/queries/__generated__/fragments.generated' | ||
import { useJoystreamStore } from '@/providers/joystream/joystream.store' | ||
|
||
// import { useJoystreamStore } from '@/providers/joystream/joystream.store' | ||
|
||
export const useIsTokenInLockedMode = (token?: FullCreatorTokenFragment) => { | ||
const currentBlockRef = useRef(useJoystreamStore((store) => store.currentBlock)) | ||
// const currentBlockRef = useRef(useJoystreamStore((store) => store.currentBlock)) | ||
// 1. Check if there is any unfinalized revenue share | ||
const activeRevenueShare = token?.revenueShares.find((rS) => !rS.finalized) | ||
|
||
// 2. If ending block is not yet came for a user, consider that the token is locked | ||
const hasActiveRevenueShare = (activeRevenueShare?.endsAt ?? 0) > currentBlockRef.current | ||
// BUG: looks like runtime doesnt allow to make tx if the revenue share not finalized | ||
// const hasActiveRevenueShare = (activeRevenueShare?.endsAt ?? 0) > currentBlockRef.current | ||
|
||
return hasActiveRevenueShare | ||
return !!activeRevenueShare | ||
} |