From 480743b6f7950ac6907e75d44089f115cdbc84ab Mon Sep 17 00:00:00 2001 From: aymericdelab Date: Tue, 17 Dec 2024 17:32:09 +0100 Subject: [PATCH 1/3] 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]; From cb2a7ed3dc131897c12d4138cf0ac674b1be8a7b Mon Sep 17 00:00:00 2001 From: bal7hazar Date: Tue, 17 Dec 2024 19:07:38 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20Fix=20undefined=20deposites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/hooks/helpers/use-resource-arrivals.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From e21b6004207cc88c70c708e43ed580c872bcb698 Mon Sep 17 00:00:00 2001 From: aymericdelab Date: Tue, 17 Dec 2024 22:03:20 +0100 Subject: [PATCH 3/3] ceiling amount contribute --- .../components/hyperstructures/HyperstructureResourceChip.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);