galacticcouncil / hydration-ui

8 stars 11 forks source link

Staking page keeps removing previous loaded information when reloading #1480

Closed gui1117 closed 4 weeks ago

gui1117 commented 1 month ago

Staking page keeps removing previous loaded information when reloading,

I looked at the code it seems the referendas query always return true to isInitialLoading:

https://github.com/galacticcouncil/HydraDX-ui/blob/e83c1e4d27904728bc0b63927932756005991ebe/src/sections/staking/StakingPage.utils.ts#L102-L112

I think this query must be fixed somehow

gui1117 commented 1 month ago

Moreover if I print queries[6].isError I get true.

I did this diff:

diff --git a/src/sections/staking/StakingPage.utils.ts b/src/sections/staking/StakingPage.utils.ts
index 8987660a..4c02d192 100644
--- a/src/sections/staking/StakingPage.utils.ts
+++ b/src/sections/staking/StakingPage.utils.ts
@@ -110,6 +110,8 @@ export const useStakeData = () => {
   ]

   const isLoading = queries.some((query) => query.isInitialLoading)
+  console.log("is referenda initial", queries[6].isInitialLoading)
+  console.log("is referenda error", queries[6].isError)

   const data = useMemo(() => {
     if (isLoading) return undefined

I get this in the console:

is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
Error: Cannot convert 'Split' via asStandard
    with Enum.js:173
    get property.js:21
    referendums democracy.ts:69
    getReferendums democracy.ts:58
    fetchFn query.ts:400
    run retryer.ts:147
    run retryer.ts:196
    promise callback*createRetryer/run/< retryer.ts:192
    promise callback*run retryer.ts:154
    run retryer.ts:196
    promise callback*createRetryer/run/< retryer.ts:192
    promise callback*run retryer.ts:154
    run retryer.ts:196
    promise callback*createRetryer/run/< retryer.ts:192
    promise callback*run retryer.ts:154
    createRetryer retryer.ts:204
    fetch query.ts:458
    executeFetch queryObserver.ts:350
    setOptions queryObserver.ts:203
    useBaseQuery useBaseQuery.ts:100
    React 16
    setState vanilla.mjs:9
    setState vanilla.mjs:9
    configResult middleware.mjs:357
    setRpcUrl provider.ts:105
    onSettled provider.ts:217
    batchCalls notifyManager.ts:55
    notifyFn notifyManager.ts:17
[staking:12714:25](http://localhost:5173/staking)
Error: Cannot convert 'Split' via asStandard
    with Enum.js:173
    get property.js:21
    referendums democracy.ts:69
    getReferendums democracy.ts:58
    fetchFn query.ts:400
    run retryer.ts:147
    run retryer.ts:196
    promise callback*createRetryer/run/< retryer.ts:192
    promise callback*run retryer.ts:154
    run retryer.ts:196
    promise callback*createRetryer/run/< retryer.ts:192
    promise callback*run retryer.ts:154
    run retryer.ts:196
    promise callback*createRetryer/run/< retryer.ts:192
    promise callback*run retryer.ts:154
    createRetryer retryer.ts:204
    fetch query.ts:458
    executeFetch queryObserver.ts:350
    onSubscribe queryObserver.ts:107
    subscribe subscribable.ts:15
    useBaseQuery useBaseQuery.ts:81
    React 17
    setState vanilla.mjs:9
    setState vanilla.mjs:9
    configResult middleware.mjs:357
    setRpcUrl provider.ts:105
    onSettled provider.ts:217
[staking:12714:25](http://localhost:5173/staking)
is referenda initial false [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error true [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial false [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error true [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial false [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error true [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial false [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error true [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial false [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error true [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false [StakingPage.utils.ts:114:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda initial true [StakingPage.utils.ts:113:10](http://localhost:5173/src/sections/staking/StakingPage.utils.ts)
is referenda error false
gui1117 commented 1 month ago

I am pretty sure it is because of this:

https://github.com/galacticcouncil/HydraDX-ui/blob/e83c1e4d27904728bc0b63927932756005991ebe/src/api/democracy.ts#L69-L70

I did voted with a split vote one time.

gui1117 commented 1 month ago

I removed my split vote and now everything works good.

jak-pan commented 1 month ago

I removed my split vote and now everything works good.

Thank you for debugging this 👍🏻 Would you be willing to do PR to fix this? (Tip coming)