Skip to content

Commit

Permalink
fix sync
Browse files Browse the repository at this point in the history
  • Loading branch information
aymericdelab committed Dec 12, 2024
1 parent e9ad1ea commit 2517810
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
24 changes: 15 additions & 9 deletions client/src/dojo/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ export const addToSubscription = async <S extends Schema>(
},
};

await getEntities(
client,
{
...positionClause,
},
components,
10_000,
false,
);
position &&
(await getEntities(
client,
{
...positionClause,
},
components,
10_000,
false,
));

await getEntities(
client,
Expand All @@ -89,7 +90,12 @@ export const addToSubscription = async <S extends Schema>(
10_000,
false,
);
};

export const addMarketSubscription = async <S extends Schema>(
client: ToriiClient,
components: Component<S, Metadata, undefined>[],
) => {
await getEntities(
client,
{
Expand Down
8 changes: 7 additions & 1 deletion client/src/ui/layouts/World.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { lazy, Suspense, useEffect, useMemo, useState } from "react";
import { Redirect } from "wouter";
import useUIStore from "../../hooks/store/useUIStore";

import { addToSubscription } from "@/dojo/queries";
import { addMarketSubscription, addToSubscription } from "@/dojo/queries";
import { useDojo } from "@/hooks/context/DojoContext";
import { PlayerStructure, useEntities } from "@/hooks/helpers/useEntities";
import { useStructureEntityId } from "@/hooks/helpers/useStructureEntityId";
Expand Down Expand Up @@ -140,6 +140,12 @@ export const World = ({ backgroundImage }: { backgroundImage: string }) => {
setWorldLoading(false);
}

try {
await addMarketSubscription(dojo.network.toriiClient, dojo.network.contractComponents as any);
} catch (error) {
console.error("Fetch failed", error);
}

console.log("world loading", worldLoading);
};

Expand Down

0 comments on commit 2517810

Please sign in to comment.