Skip to content

Commit

Permalink
Fixes e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacomyal committed Jan 30, 2024
1 parent cd529b5 commit 12e92b7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/core/Initialize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { useFileActions } from "./context/dataContexts";
import { filtersAtom } from "./filters";
import { parseFiltersState } from "./filters/utils";
import { graphDatasetAtom } from "./graph";
import { fileStateAtom } from "./graph/files";
import { getEmptyGraphDataset, parseDataset } from "./graph/utils";
import { useModal } from "./modals";
import { useNotifications } from "./notifications";
Expand All @@ -22,6 +21,11 @@ import { getEmptySession, parseSession } from "./session/utils";
import { resetCamera } from "./sigma";
import { AuthInit } from "./user/AuthInit";

// This awful flag helps dealing with the double rendering caused from
// React.StrictMode:
// https://react.dev/reference/react/StrictMode#fixing-bugs-found-by-double-rendering-in-development
let isInitialized = false;

export const Initialize: FC<PropsWithChildren<unknown>> = ({ children }) => {
const { t } = useTranslation();
const { notify } = useNotifications();
Expand Down Expand Up @@ -59,6 +63,9 @@ export const Initialize: FC<PropsWithChildren<unknown>> = ({ children }) => {
* - ...
*/
const initialize = useCallback(async () => {
if (isInitialized) return;
isInitialized = true;

// Load session from local storage
sessionAtom.set(() => {
const raw = sessionStorage.getItem("session");
Expand Down Expand Up @@ -86,8 +93,7 @@ export const Initialize: FC<PropsWithChildren<unknown>> = ({ children }) => {

// If query params has gexf
// => try to load the file
const isIdle = fileStateAtom.get().type === "idle";
if (!graphFound && url.searchParams.has("gexf") && isIdle) {
if (!graphFound && url.searchParams.has("gexf")) {
const gexfUrl = url.searchParams.get("gexf") || "";
try {
await openRemoteFile({
Expand Down Expand Up @@ -128,7 +134,6 @@ export const Initialize: FC<PropsWithChildren<unknown>> = ({ children }) => {
appearanceAtom.set((prev) => appearance || prev);
resetCamera({ forceRefresh: true });

graphFound = true;
if (dataset.fullGraph.order > 0) showWelcomeModal = false;
}
}
Expand Down

0 comments on commit 12e92b7

Please sign in to comment.