From 480743b6f7950ac6907e75d44089f115cdbc84ab Mon Sep 17 00:00:00 2001 From: aymericdelab Date: Tue, 17 Dec 2024 17:32:09 +0100 Subject: [PATCH] use blocktimestamp hook --- client/src/ui/components/entities/Entity.tsx | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/client/src/ui/components/entities/Entity.tsx b/client/src/ui/components/entities/Entity.tsx index 6dd2fff63..265777685 100644 --- a/client/src/ui/components/entities/Entity.tsx +++ b/client/src/ui/components/entities/Entity.tsx @@ -3,14 +3,14 @@ import { ArrivalInfo } from "@/hooks/helpers/use-resource-arrivals"; import { getArmyByEntityId } from "@/hooks/helpers/useArmies"; import { useEntitiesUtils } from "@/hooks/helpers/useEntities"; import { useResourcesUtils } from "@/hooks/helpers/useResources"; -import useUIStore from "@/hooks/store/useUIStore"; +import useNextBlockTimestamp from "@/hooks/useNextBlockTimestamp"; import { ArmyCapacity } from "@/ui/elements/ArmyCapacity"; import { ResourceCost } from "@/ui/elements/ResourceCost"; import { divideByPrecision, formatTime, getEntityIdFromKeys } from "@/ui/utils/utils"; import { EntityType } from "@bibliothecadao/eternum"; import { useComponentValue } from "@dojoengine/react"; import clsx from "clsx"; -import React, { useMemo, useState } from "react"; +import React, { useMemo } from "react"; import { DepositResources } from "../resources/DepositResources"; const entityIcon: Record = { @@ -35,11 +35,9 @@ const CACHE_DURATION = 2 * 60 * 1000; // 2 minutes in milliseconds export const EntityArrival = ({ arrival, ...props }: EntityProps) => { const dojo = useDojo(); - const [isSyncing, setIsSyncing] = useState(false); - const { getEntityInfo, getEntityName } = useEntitiesUtils(); const { getResourcesFromBalance } = useResourcesUtils(); - const nextBlockTimestamp = useUIStore.getState().nextBlockTimestamp; + const { nextBlockTimestamp } = useNextBlockTimestamp(); const { getArmy } = getArmyByEntityId(); const weight = useComponentValue(dojo.setup.components.Weight, getEntityIdFromKeys([BigInt(arrival.entityId)])); @@ -68,10 +66,6 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => { }, [nextBlockTimestamp, arrival.recipientEntityId, arrival.hasResources, entity.arrivalTime]); const renderedResources = useMemo(() => { - if (isSyncing) { - return
Syncing resources...
; - } - return entityResources .filter(Boolean) .map((resource) => ( @@ -85,7 +79,7 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => { amount={divideByPrecision(resource.amount)} /> )); - }, [entityResources, isSyncing]); + }, [entityResources]); const name = entity.entityType === EntityType.TROOP ? army?.name : entityName[entity.entityType];