Skip to content

Commit 0d52ff8

Browse files
authored
Revert "fix: unlocked cycle upcoming state" (#4195)
1 parent 829f597 commit 0d52ff8

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

src/components/v2v3/V2V3Project/ProjectDashboard/components/CyclesPayoutsPanel/components/CurrentUpcomingSubPanel.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,16 @@ export const CurrentUpcomingSubPanel = ({
6363
</Trans>
6464
)
6565

66-
const hasNoUpcomingCycle =
66+
if (
6767
info.type === 'upcoming' &&
6868
info.currentCycleUnlocked &&
6969
/**
7070
* Always show 'upcoming' tab if it's FC 1
7171
* (which happens when Scheduled Launch is used,
7272
* mustStartAtOrAfter is in the future)
7373
*/
74-
info.cycleNumber !== 1 &&
75-
!info.hasPendingConfiguration
76-
77-
if (hasNoUpcomingCycle) {
74+
info.cycleNumber !== 1
75+
) {
7876
return (
7977
<div>
8078
<div

src/components/v2v3/V2V3Project/ProjectDashboard/components/CyclesPayoutsPanel/hooks/useCurrentUpcomingSubPanel.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useProjectContext } from 'components/v2v3/V2V3Project/ProjectDashboard/
44
import { useProjectMetadata } from 'components/v2v3/V2V3Project/ProjectDashboard/hooks/useProjectMetadata'
55
import { timeSecondsToDateString } from 'components/v2v3/V2V3Project/ProjectDashboard/utils/timeSecondsToDateString'
66
import { useProjectUpcomingFundingCycle } from 'hooks/v2v3/contractReader/useProjectUpcomingFundingCycle'
7-
import { BallotState } from 'models/v2v3/fundingCycle'
87
import { useMemo } from 'react'
98

109
export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
@@ -16,14 +15,8 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
1615
const {
1716
data: upcomingFundingCycleData,
1817
loading: upcomingFundingCycleLoading,
19-
} = useProjectUpcomingFundingCycle({
20-
projectId,
21-
/**
22-
* if the current cycle is unlocked, force the use of latestConfiguredFundingCycleOf.
23-
*/
24-
useLatestConfigured: fundingCycle?.duration?.isZero() ?? false,
25-
})
26-
const [upcomingFundingCycle, , ballotState] = upcomingFundingCycleData ?? []
18+
} = useProjectUpcomingFundingCycle({ projectId })
19+
const [upcomingFundingCycle] = upcomingFundingCycleData ?? []
2720
const { timeRemainingText } = useFundingCycleCountdown()
2821

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

36+
/** Determines if the CURRENT cycle is unlocked.
37+
* This is used to check if the upcoming cycle can start at any time. */
38+
const currentCycleUnlocked = useMemo(() => {
39+
return fundingCycle?.duration?.isZero() ?? true
40+
}, [fundingCycle?.duration])
41+
4342
const upcomingCycleLength = useMemo(() => {
4443
if (!upcomingFundingCycle) return
4544
if (cycleUnlocked) return '-'
@@ -49,12 +48,15 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
4948
)
5049
}, [cycleUnlocked, upcomingFundingCycle])
5150

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

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

5961
// Short circuit current for faster loading
6062
if (type === 'current') {
@@ -82,14 +84,5 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
8284
cycleLength: upcomingCycleLength,
8385
cycleUnlocked,
8486
currentCycleUnlocked,
85-
hasPendingConfiguration:
86-
/**
87-
* If a cycle is unlocked, it may have a pending change.
88-
* The only way it would, is if the ballot state of the latestConfiguredFC is `approved`.
89-
*/
90-
cycleUnlocked &&
91-
typeof ballotState !== 'undefined' &&
92-
ballotState !== null &&
93-
ballotState === BallotState.approved,
9487
}
9588
}

src/hooks/v2v3/contractReader/useProjectUpcomingFundingCycle.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ type UpcomingFundingCycleDataType = [
1919
*/
2020
export function useProjectUpcomingFundingCycle({
2121
projectId,
22-
useLatestConfigured, // force latestConfiguredFundingCycleOf to be returned.
2322
}: {
2423
projectId: number | undefined
25-
useLatestConfigured?: boolean
2624
}): ContractReadResult<UpcomingFundingCycleDataType> {
2725
/**
2826
* Get Latest Configured Funding Cycle.
@@ -40,9 +38,8 @@ export function useProjectUpcomingFundingCycle({
4038
latestConfiguredFundingCycleBallotState,
4139
] = latestConfiguredFundingCycleResponse ?? []
4240
const isLatestConfiguredActive =
43-
(latestConfiguredFundingCycle &&
44-
latestConfiguredFundingCycleBallotState === BallotState.active) ||
45-
useLatestConfigured
41+
latestConfiguredFundingCycle &&
42+
latestConfiguredFundingCycleBallotState === BallotState.active
4643

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

0 commit comments

Comments
 (0)