Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 project page: volume charts #4452

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/components/VolumeChart/hooks/useProjectTimeline.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { useQuery } from '@tanstack/react-query'
import { PV_V2, PV_V4 } from 'constants/pv'
import { readProvider } from 'constants/readProvider'
import { RomanStormVariables } from 'constants/romanStorm'
import EthDater from 'ethereum-block-by-date'
import {
ProjectTlQuery,
useProjectsQuery,
useProjectTlQuery,
} from 'generated/graphql'
import { ProjectTlQuery, useProjectsQuery, useProjectTlQuery } from 'generated/graphql'
import { client } from 'lib/apollo/client'
import { PV } from 'models/pv'
import { ProjectTlDocument } from 'packages/v4/graphql/client/graphql'
Expand All @@ -15,7 +12,6 @@ import { useMemo } from 'react'
import { wadToFloat } from 'utils/format/formatNumber'
import { getSubgraphIdForProject } from 'utils/graph'
import { daysToMS, minutesToMS } from 'utils/units'
import { RomanStormVariables } from 'constants/romanStorm'

import { ProjectTimelinePoint, ProjectTimelineRange } from '../types'

Expand Down Expand Up @@ -105,13 +101,14 @@ export function useProjectTimeline({
skip: pv === PV_V4,
})


const { data: v4QueryResult } = useSubgraphQuery({
document: ProjectTlDocument,
document: ProjectTlDocument,
variables: {
id: blocks ? projectId.toString() : '',
...blocks,
},
enabled: pv === PV_V4,
enabled: pv === PV_V4
})

const points = useMemo(() => {
Expand All @@ -121,9 +118,7 @@ export function useProjectTimeline({
const points: ProjectTimelinePoint[] = []

for (let i = 0; i < COUNT; i++) {
const point = (queryResult as ProjectTlQuery)[
`p${i}` as keyof typeof queryResult
]
const point = (queryResult as ProjectTlQuery)[`p${i}` as keyof typeof queryResult]

if (!point) continue
if (exceptionTimestamp && exceptionTimestamp > timestamps[i]) {
Expand All @@ -149,7 +144,7 @@ export function useProjectTimeline({
}

return points
}, [timestamps, v1v2v3QueryResult, v4QueryResult, pv])
}, [timestamps, v1v2v3QueryResult, v4QueryResult, pv, projectId, exceptionTimestamp, romanStormData?.projects])

return {
points,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export function V4ActivityList() {

// TODO: pageSize (pagination)
const { data: payEventsData, isLoading } = useSubgraphQuery({
document: PayEventsDocument,
document: PayEventsDocument,
variables: {
orderBy: PayEvent_OrderBy.timestamp,
orderDirection: OrderDirection.desc,
where: {
projectId: Number(projectId),
},
},
}
})

const payEvents = transformPayEventsRes(payEventsData) ?? []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Trans } from '@lingui/macro'
import { ErrorBoundaryCallout } from 'components/Callout/ErrorBoundaryCallout'
import Loading from 'components/Loading'
// import VolumeChart from 'components/VolumeChart'
import VolumeChart from 'components/VolumeChart'
import { PV_V4 } from 'constants/pv'
import { useJBContractContext } from 'juice-sdk-react'
import { ProjectsDocument } from 'packages/v4/graphql/client/graphql'
import { useSubgraphQuery } from 'packages/v4/graphql/useSubgraphQuery'
Expand All @@ -11,14 +12,14 @@ import { V4ActivityList } from './V4ActivityList'
export function V4ActivityPanel() {
const { projectId } = useJBContractContext()
const { data } = useSubgraphQuery({
document: ProjectsDocument,
document: ProjectsDocument,
variables: {
where: {
projectId: Number(projectId),
},
},
}
})

const createdAt = data?.projects?.[0].createdAt

return (
Expand All @@ -29,12 +30,12 @@ export function V4ActivityPanel() {
<ErrorBoundaryCallout
message={<Trans>Volume chart failed to load.</Trans>}
>
{/* <VolumeChart
<VolumeChart
height={240}
projectId={Number(projectId)}
createdAt={createdAt}
pv={PV_V4}
/> */}
/>
</ErrorBoundaryCallout>
</Suspense>
</div>
Expand Down
Loading