Skip to content

Commit

Permalink
Fix: Token amounts in milestone block page's referenced blocks (#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
brancoder authored Jan 26, 2024
1 parent 7247b7d commit 44fa7d8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions client/src/helpers/hooks/useInputsAndOutputs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Block, Unlock, PayloadType } from "@iota/sdk-wasm/web";
import { useContext, useEffect, useState } from "react";
import { useIsMounted } from "./useIsMounted";
import NetworkContext from "~app/context/NetworkContext";
import { ServiceFactory } from "~factories/serviceFactory";
import { IInput } from "~models/api/stardust/IInput";
Expand All @@ -19,7 +18,6 @@ export function useInputsAndOutputs(
network: string,
block: Block | null,
): [IInput[] | null, Unlock[] | null, IOutput[] | null, number | null, boolean] {
const isMounted = useIsMounted();
const [apiClient] = useState(ServiceFactory.get<StardustApiClient>(`api-client-${STARDUST}`));
const { bech32Hrp } = useContext(NetworkContext);
const [tsxInputs, setInputs] = useState<IInput[] | null>(null);
Expand All @@ -30,7 +28,13 @@ export function useInputsAndOutputs(
const [isLoading, setIsLoading] = useState<boolean>(true);

useEffect(() => {
let isMounted = true;

setIsLoading(true);
setTransferTotal(null);
setInputs(null);
setUnlocks(null);
setOutputs(null);
if (block?.payload?.type === PayloadType.Transaction) {
// eslint-disable-next-line no-void
void (async () => {
Expand All @@ -51,6 +55,10 @@ export function useInputsAndOutputs(
} else {
setIsLoading(false);
}

return () => {
isMounted = false;
};
}, [network, block]);

return [tsxInputs, tsxUnlocks, tsxOutputs, tsxTransferTotal, isLoading];
Expand Down

0 comments on commit 44fa7d8

Please sign in to comment.