Skip to content

Commit

Permalink
[#541] fix dashboard infinte loading
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dyczka committed Mar 27, 2024
1 parent 4eec162 commit 3f62209
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
13 changes: 9 additions & 4 deletions govtool/frontend/src/components/organisms/DashboardCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ export const DashboardCards = () => {
} = useCardano();
const { screenWidth } = useScreenDimension();

const { currentDelegation } = useGetAdaHolderCurrentDelegationQuery(stakeKey);
const { votingPower } = useGetAdaHolderVotingPowerQuery(stakeKey);
const { voter } = useGetVoterInfo();
const { currentDelegation, isCurrentDelegationLoading }
= useGetAdaHolderCurrentDelegationQuery(stakeKey);
const { votingPower, powerIsLoading } = useGetAdaHolderVotingPowerQuery(stakeKey);
const { voter, isVoterLoading } = useGetVoterInfo();

if (!currentDelegation || !voter || !votingPower) {
if (
(currentDelegation === undefined && isCurrentDelegationLoading)
|| (votingPower === undefined && powerIsLoading)
|| (voter === undefined && isVoterLoading)
) {
return (
<Box
sx={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { VoterInfo } from "@/models";
type DRepDashboardCardProps = {
dRepIDBech32: string;
pendingTransaction: PendingTransaction;
voter: VoterInfo;
voter: VoterInfo | undefined;
};

export const DRepDashboardCard = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DashboardActionCard } from "@molecules";
import { VoterInfo } from "@/models";

type ListGovActionsDashboardCardsProps = {
voter: VoterInfo;
voter: VoterInfo | undefined;
};

export const ListGovActionsDashboardCards = ({ voter }: ListGovActionsDashboardCardsProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { VoterInfo } from "@/models";

type SoleVoterDashboardCardProps = {
pendingTransaction: PendingTransaction;
voter: VoterInfo;
voter: VoterInfo | undefined;
votingPower: number;
};

Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/src/hooks/queries/useGetVoterInfoQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getVoterInfo } from "@services";
export const useGetVoterInfo = () => {
const { dRepID, pendingTransaction } = useCardano();

const { data } = useQuery({
const { data, isLoading } = useQuery({
queryKey: [
QUERY_KEYS.useGetDRepInfoKey,
(pendingTransaction.registerAsDrep ||
Expand All @@ -19,5 +19,5 @@ export const useGetVoterInfo = () => {
queryFn: () => getVoterInfo(dRepID),
});

return { voter: data };
return { voter: data, isVoterLoading: isLoading };
};

0 comments on commit 3f62209

Please sign in to comment.