diff --git a/client/src/hooks/helpers/use-resource-arrivals.tsx b/client/src/hooks/helpers/use-resource-arrivals.tsx index 9dd7396bd..ef7af8933 100644 --- a/client/src/hooks/helpers/use-resource-arrivals.tsx +++ b/client/src/hooks/helpers/use-resource-arrivals.tsx @@ -83,7 +83,7 @@ const usePlayerArrivals = () => { const ownedResourceTracker = getComponentValue(OwnedResourcesTracker, id); - const hasResources = ownedResourceTracker?.resource_types !== 0n; + const hasResources = !!ownedResourceTracker && ownedResourceTracker.resource_types !== 0n; const playerStructurePosition = playerStructurePositions.find( (structurePosition) => structurePosition.x === position.x && structurePosition.y === position.y, 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]; diff --git a/client/src/ui/components/hyperstructures/HyperstructureResourceChip.tsx b/client/src/ui/components/hyperstructures/HyperstructureResourceChip.tsx index a92fbacf1..2831a8510 100644 --- a/client/src/ui/components/hyperstructures/HyperstructureResourceChip.tsx +++ b/client/src/ui/components/hyperstructures/HyperstructureResourceChip.tsx @@ -37,7 +37,7 @@ export const HyperstructureResourceChip = ({ let maxContributableAmount = Math.min(progress.costNeeded! - progress.amount, balance); maxContributableAmount *= progress.costNeeded - progress.amount > balance ? safetyMargin : 1; - maxContributableAmount = Math.floor(maxContributableAmount); + maxContributableAmount = Math.ceil(maxContributableAmount); useEffect(() => { let contributionsCopy = Object.assign({}, contributions);