Skip to content

Commit

Permalink
Revert "fix: unlocked cycle upcoming state" (#4195)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyd-eth authored Jan 15, 2024
1 parent 829f597 commit 0d52ff8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,16 @@ export const CurrentUpcomingSubPanel = ({
</Trans>
)

const hasNoUpcomingCycle =
if (
info.type === 'upcoming' &&
info.currentCycleUnlocked &&
/**
* Always show 'upcoming' tab if it's FC 1
* (which happens when Scheduled Launch is used,
* mustStartAtOrAfter is in the future)
*/
info.cycleNumber !== 1 &&
!info.hasPendingConfiguration

if (hasNoUpcomingCycle) {
info.cycleNumber !== 1
) {
return (
<div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useProjectContext } from 'components/v2v3/V2V3Project/ProjectDashboard/
import { useProjectMetadata } from 'components/v2v3/V2V3Project/ProjectDashboard/hooks/useProjectMetadata'
import { timeSecondsToDateString } from 'components/v2v3/V2V3Project/ProjectDashboard/utils/timeSecondsToDateString'
import { useProjectUpcomingFundingCycle } from 'hooks/v2v3/contractReader/useProjectUpcomingFundingCycle'
import { BallotState } from 'models/v2v3/fundingCycle'
import { useMemo } from 'react'

export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
Expand All @@ -16,14 +15,8 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
const {
data: upcomingFundingCycleData,
loading: upcomingFundingCycleLoading,
} = useProjectUpcomingFundingCycle({
projectId,
/**
* if the current cycle is unlocked, force the use of latestConfiguredFundingCycleOf.
*/
useLatestConfigured: fundingCycle?.duration?.isZero() ?? false,
})
const [upcomingFundingCycle, , ballotState] = upcomingFundingCycleData ?? []
} = useProjectUpcomingFundingCycle({ projectId })
const [upcomingFundingCycle] = upcomingFundingCycleData ?? []
const { timeRemainingText } = useFundingCycleCountdown()

const cycleNumber = useMemo(() => {
Expand All @@ -40,6 +33,12 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
return upcomingFundingCycle?.duration?.isZero() ?? true
}, [fundingCycle?.duration, type, upcomingFundingCycle?.duration])

/** Determines if the CURRENT cycle is unlocked.
* This is used to check if the upcoming cycle can start at any time. */
const currentCycleUnlocked = useMemo(() => {
return fundingCycle?.duration?.isZero() ?? true
}, [fundingCycle?.duration])

const upcomingCycleLength = useMemo(() => {
if (!upcomingFundingCycle) return
if (cycleUnlocked) return '-'
Expand All @@ -49,12 +48,15 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
)
}, [cycleUnlocked, upcomingFundingCycle])

/** Determines if the CURRENT cycle is unlocked.
* This is used to check if the upcoming cycle can start at any time. */
const currentCycleUnlocked = fundingCycle?.duration?.isZero() ?? true
const status = useMemo(() => {
if (cycleUnlocked) return t`Unlocked`
return t`Locked`
}, [cycleUnlocked])

const status = cycleUnlocked ? t`Unlocked` : t`Locked`
const remainingTime = cycleUnlocked ? '-' : timeRemainingText
const remainingTime = useMemo(() => {
if (cycleUnlocked) return '-'
return timeRemainingText
}, [cycleUnlocked, timeRemainingText])

// Short circuit current for faster loading
if (type === 'current') {
Expand Down Expand Up @@ -82,14 +84,5 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
cycleLength: upcomingCycleLength,
cycleUnlocked,
currentCycleUnlocked,
hasPendingConfiguration:
/**
* If a cycle is unlocked, it may have a pending change.
* The only way it would, is if the ballot state of the latestConfiguredFC is `approved`.
*/
cycleUnlocked &&
typeof ballotState !== 'undefined' &&
ballotState !== null &&
ballotState === BallotState.approved,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ type UpcomingFundingCycleDataType = [
*/
export function useProjectUpcomingFundingCycle({
projectId,
useLatestConfigured, // force latestConfiguredFundingCycleOf to be returned.
}: {
projectId: number | undefined
useLatestConfigured?: boolean
}): ContractReadResult<UpcomingFundingCycleDataType> {
/**
* Get Latest Configured Funding Cycle.
Expand All @@ -40,9 +38,8 @@ export function useProjectUpcomingFundingCycle({
latestConfiguredFundingCycleBallotState,
] = latestConfiguredFundingCycleResponse ?? []
const isLatestConfiguredActive =
(latestConfiguredFundingCycle &&
latestConfiguredFundingCycleBallotState === BallotState.active) ||
useLatestConfigured
latestConfiguredFundingCycle &&
latestConfiguredFundingCycleBallotState === BallotState.active

/**
* Get Queued Configured Funding Cycle, *only if* latestConfiguredFundingCycle isn't active.
Expand Down

1 comment on commit 0d52ff8

@vercel
Copy link

@vercel vercel bot commented on 0d52ff8 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.