Skip to content

Commit

Permalink
fix: remove network check on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
noyyyy committed Oct 19, 2024
1 parent 7d8ce8a commit 9cd1e1d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/client/src/ui/hooks/useCheckNetworkHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export function useCheckNetworkHealth() {
const errorHandler = (event: ErrorEvent): void => {
logDebug("Global error:", event.error);

logDebug("readyState: ", document.readyState);

if (
document.readyState !== "loading" &&
event.error &&
(event.error.toString().includes("RuntimeError: unreachable") ||
event.error
Expand All @@ -18,10 +21,16 @@ export function useCheckNetworkHealth() {
}
};

const beforeReloadHandler = (): void => {
window.removeEventListener("error", errorHandler);
};

window.addEventListener("error", errorHandler);
window.addEventListener("beforeunload", beforeReloadHandler);

return () => {
window.removeEventListener("error", errorHandler);
window.removeEventListener("beforeunload", beforeReloadHandler);
};
}, []);

Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/ui/hooks/useControlGameEnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { zeroEntity } from "../../utils";
import { getEntityIdFromKeys } from "@dojoengine/utils";
import { useEffect, useMemo } from "react";
import { ShowItem, useUIStore } from "../../store";
import { logDebug } from "../lib/utils";

export function useGameEnd() {
const {
Expand All @@ -19,6 +20,13 @@ export function useGameEnd() {
getEntityIdFromKeys([BigInt(s?.currentMatch ?? 0)])
);

logDebug(
"check player in match and game end",
playerValue,
s?.currentMatch,
result
);

const end = useMemo(() => {
let e = false;

Expand Down

0 comments on commit 9cd1e1d

Please sign in to comment.