auto update UI after any action on the detailed view
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
7733a6cd3b
commit
de84f8e40f
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.5.30",
|
"version": "0.5.31",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { useEffect, useState, useMemo } from "react";
|
import { useEffect, useState, useMemo } from "react";
|
||||||
import ReactGA from "react-ga4";
|
import ReactGA from "react-ga4";
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useBlock, useBlockNumber } from 'wagmi'
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { useBlock, useBlockNumber } from "wagmi";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
@ -72,6 +73,7 @@ import RepeatIcon from '@mui/icons-material/Repeat';
|
|||||||
|
|
||||||
const HUNDRED = new DecimalBigNumber(100n, 0);
|
const HUNDRED = new DecimalBigNumber(100n, 0);
|
||||||
|
|
||||||
|
|
||||||
const ProposalDetails = ({ chainId, address, connect, config }) => {
|
const ProposalDetails = ({ chainId, address, connect, config }) => {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const proposalId = BigInt(id);
|
const proposalId = BigInt(id);
|
||||||
@ -84,6 +86,7 @@ const ProposalDetails = ({ chainId, address, connect, config }) => {
|
|||||||
const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
|
const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST");
|
const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST");
|
||||||
const { balance } = useBalance(chainId, "GHST", address);
|
const { balance } = useBalance(chainId, "GHST", address);
|
||||||
@ -173,20 +176,22 @@ const ProposalDetails = ({ chainId, address, connect, config }) => {
|
|||||||
proposals.push(proposalId);
|
proposals.push(proposalId);
|
||||||
const toStore = JSON.stringify(proposals.map(id => id.toString()));
|
const toStore = JSON.stringify(proposals.map(id => id.toString()));
|
||||||
localStorage.setItem(`${VOTED_PROPOSALS_PREFIX}-${address}`, toStore);
|
localStorage.setItem(`${VOTED_PROPOSALS_PREFIX}-${address}`, toStore);
|
||||||
|
await queryClient.invalidateQueries();
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsPending(false);
|
setIsPending(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleExecute = async () => {
|
const handleExecute = async () => {
|
||||||
setIsPending(true);
|
setIsPending(true);
|
||||||
await executeProposal(chainId, address, proposalId);
|
await executeProposal(chainId, address, proposalId);
|
||||||
|
await queryClient.invalidateQueries();
|
||||||
setIsPending(false);
|
setIsPending(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRelease = async (proposalId) => {
|
const handleRelease = async (proposalId) => {
|
||||||
setIsPending(true);
|
setIsPending(true);
|
||||||
await releaseLocked(chainId, address, proposalId);
|
await releaseLocked(chainId, address, proposalId);
|
||||||
|
await queryClient.invalidateQueries();
|
||||||
setIsPending(false);
|
setIsPending(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +406,7 @@ const VotingTimeline = ({ connect, handleExecute, handleRelease, proposalLocked,
|
|||||||
<VotingTimelineItem chainId={chainId} occured={proposalDeadline} message="Voting ends" />
|
<VotingTimelineItem chainId={chainId} occured={proposalDeadline} message="Voting ends" />
|
||||||
</Timeline>
|
</Timeline>
|
||||||
<Box width="100%" display="flex" gap="10px">
|
<Box width="100%" display="flex" gap="10px">
|
||||||
{(isProposer || (proposalLocked?._value ?? 0n) > 0n) && <SecondaryButton
|
{(isProposer && (proposalLocked?._value ?? 0n) > 0n) && <SecondaryButton
|
||||||
fullWidth
|
fullWidth
|
||||||
disabled={isPending || state < 2}
|
disabled={isPending || state < 2}
|
||||||
onClick={() => address === "" ? connect() : handleRelease()}
|
onClick={() => address === "" ? connect() : handleRelease()}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user