Skip to content

Commit a09beda

Browse files
committed
v4v5 timeline fix
1 parent 793475f commit a09beda

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/components/VolumeChart/hooks/useProjectTimeline.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export function useProjectTimeline({
2929
}) {
3030
const chainId = useJBChainId()
3131

32+
const isV4V5 = pv === PV_V4 || pv === PV_V5
33+
3234
const exceptionTimestamp = useMemo(() => {
3335
return RomanStormVariables.PROJECT_ID === projectId
3436
? RomanStormVariables.SNAPSHOT_TIMESTAMP
@@ -38,7 +40,7 @@ export function useProjectTimeline({
3840
const { data: romanStormData } = useProjectsQuery({
3941
client,
4042
fetchPolicy: 'no-cache',
41-
skip: projectId !== RomanStormVariables.PROJECT_ID || pv === PV_V4,
43+
skip: projectId !== RomanStormVariables.PROJECT_ID || isV4V5,
4244
variables: {
4345
where: {
4446
projectId,
@@ -101,7 +103,7 @@ export function useProjectTimeline({
101103
id: blocks ? getSubgraphIdForProject(pv, projectId) : '',
102104
...blocks,
103105
},
104-
skip: pv === PV_V4,
106+
skip: isV4V5,
105107
})
106108

107109
const { data: project } = useProjectQuery({
@@ -111,12 +113,12 @@ export function useProjectTimeline({
111113
projectId,
112114
version: parseInt(pv),
113115
},
114-
skip: (pv !== PV_V4 && pv !== PV_V5) || !chainId || !projectId,
116+
skip: !isV4V5 || !chainId || !projectId,
115117
})
116118

117119
const { data: v4v5QueryResult } = useSuckerGroupTlQuery({
118120
client: bendystrawClient,
119-
skip: (pv !== PV_V4 && pv !== PV_V5) || !project?.project?.suckerGroupId,
121+
skip: !isV4V5 || !project?.project?.suckerGroupId,
120122
variables: {
121123
suckerGroupId: project?.project?.suckerGroupId,
122124
startTimestamp: timestamps?.[0],
@@ -165,7 +167,7 @@ export function useProjectTimeline({
165167
])
166168

167169
// unlike v1v2v3 points where we always query an arbitrary number of points for a specified time window, we can trust that v4 points only exist where a change has occurred, leaving no need to "fill in the gaps".
168-
const v4Points: ProjectTimelinePoint[] | undefined = useMemo(() => {
170+
const v4v5Points: ProjectTimelinePoint[] | undefined = useMemo(() => {
169171
if (!v4v5QueryResult || !timestamps || !project?.project) return
170172

171173
// first point before the current timestamp range. If undefined, assume project was created within timestamp range
@@ -219,7 +221,7 @@ export function useProjectTimeline({
219221

220222
return {
221223
v1v2v3Points,
222-
v4Points,
224+
v4v5Points,
223225
loading: isLoadingBlockNumbers || isLoadingQuery,
224226
}
225227
}

src/components/VolumeChart/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Trans } from '@lingui/macro'
22
import { PV } from 'models/pv'
33
import { CSSProperties, useMemo, useState } from 'react'
44

5-
import { PV_V4 } from 'constants/pv'
5+
import { PV_V4, PV_V5 } from 'constants/pv'
66
import RangeSelector from './components/RangeSelector'
77
import TimelineChart from './components/TimelineChart'
88
import TimelineViewSelector from './components/TimelineViewSelector'
@@ -26,7 +26,7 @@ export default function VolumeChart({
2626

2727
const [range, setRange] = useTimelineRange({ createdAt })
2828

29-
const { v1v2v3Points, v4Points, loading } = useProjectTimeline({
29+
const { v1v2v3Points, v4v5Points, loading } = useProjectTimeline({
3030
projectId,
3131
pv,
3232
range,
@@ -35,11 +35,12 @@ export default function VolumeChart({
3535
const points = useMemo(() => {
3636
switch (pv) {
3737
case PV_V4:
38-
return v4Points
38+
case PV_V5:
39+
return v4v5Points
3940
default:
4041
return v1v2v3Points
4142
}
42-
}, [pv, v1v2v3Points, v4Points])
43+
}, [pv, v1v2v3Points, v4v5Points])
4344

4445
return (
4546
<div>

0 commit comments

Comments
 (0)