Skip to content

Commit

Permalink
Merge pull request #2557 from BibliothecaDAO/next
Browse files Browse the repository at this point in the history
updates
  • Loading branch information
ponderingdemocritus authored Dec 17, 2024
2 parents 44c4f1a + 3a505c8 commit f37baae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/src/hooks/helpers/use-resource-arrivals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 4 additions & 10 deletions client/src/ui/components/entities/Entity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<EntityType, string> = {
Expand All @@ -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)]));
Expand Down Expand Up @@ -68,10 +66,6 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => {
}, [nextBlockTimestamp, arrival.recipientEntityId, arrival.hasResources, entity.arrivalTime]);

const renderedResources = useMemo(() => {
if (isSyncing) {
return <div className="text-gold/50 italic">Syncing resources...</div>;
}

return entityResources
.filter(Boolean)
.map((resource) => (
Expand All @@ -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];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f37baae

Please sign in to comment.