Skip to content

Commit

Permalink
Merge pull request #76 from CudoVentures/CUDOS-1536_infinite_load_pro…
Browse files Browse the repository at this point in the history
…posal_details

fix: using the proposal id from the link when fetching data
  • Loading branch information
stanfilip0v authored Aug 25, 2022
2 parents 7b37f67 + bf21f0f commit 0c13f08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { chainConfig } from 'configs'
import { updateProposalDetails } from 'store/proposalDetails'
import { useDispatch, useSelector } from 'react-redux'
import { RootState } from 'store'
import { useParams } from 'react-router-dom'
import {
useProposalDetailsTallyQuery,
ProposalDetailsTallyQuery,
Expand All @@ -12,6 +13,7 @@ import {

export const useVotesGraph = () => {
const dispatch = useDispatch()
const { proposalId } = useParams()
const proposalState = useSelector((state: RootState) => state.proposalDetails)

const handleSetState = (stateChange: any) => {
Expand Down Expand Up @@ -70,7 +72,7 @@ export const useVotesGraph = () => {

useProposalDetailsTallyQuery({
variables: {
proposalId: proposalState.id ? proposalState.id : 0
proposalId: Number(proposalId) || 0
},
onCompleted: (data) => {
handleSetState(foramtProposalTally(data))
Expand All @@ -79,7 +81,7 @@ export const useVotesGraph = () => {

useProposalDetailsTallySubscriptionSubscription({
variables: {
proposalId: proposalState.id ? proposalState.id : 0
proposalId: Number(proposalId) || 0
},
onSubscriptionData: (data: any) => {
handleSetState(foramtProposalTallySub(data.subscriptionData.data))
Expand Down
5 changes: 3 additions & 2 deletions src/containers/Proposals/ProposalDetails/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { useState } from 'react'
import * as R from 'ramda'
import { updateProposalDetails } from 'store/proposalDetails'
import { RootState } from 'store'
import { useDispatch, useSelector } from 'react-redux'
import { useParams } from 'react-router-dom'
import {
useProposalDetailsSubSubscription,
ProposalDetailsQuery
} from '../../../graphql/types'

export const useProposalDetails = () => {
const dispatch = useDispatch()
const { proposalId } = useParams()
const proposalState = useSelector((state: RootState) => state.proposalDetails)

const handleSetState = (stateChange: any) => {
Expand Down Expand Up @@ -75,7 +76,7 @@ export const useProposalDetails = () => {
// ==========================
useProposalDetailsSubSubscription({
variables: {
proposalId: proposalState.id ? proposalState.id : 0
proposalId: Number(proposalId) || 0
},
onSubscriptionData: (data) => {
handleSetState(formatProposalQuery(data.subscriptionData.data))
Expand Down

0 comments on commit 0c13f08

Please sign in to comment.