Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions apps/cyberstorm-remix/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ export async function clientLoader() {
publicEnvVariables.VITE_API_URL,
publicEnvVariables.VITE_COOKIE_DOMAIN
);

// We need to run this here too in addition to the, shouldRevalidate function,
// as for some reason the commits to localStorage are not done before the the clientLoader is run
sessionTools.sessionValid(
publicEnvVariables.VITE_API_URL,
publicEnvVariables.VITE_COOKIE_DOMAIN
);
const currentUser = await sessionTools.getSessionCurrentUser();
const config = sessionTools.getConfig(publicEnvVariables.VITE_API_URL);
return {
Expand All @@ -158,25 +165,22 @@ export type RootLoadersType = typeof loader | typeof clientLoader;
export function shouldRevalidate({
defaultShouldRevalidate,
}: ShouldRevalidateFunctionArgs) {
if (defaultShouldRevalidate) return true;
const publicEnvVariables = getPublicEnvVariables([
"VITE_API_URL",
"VITE_COOKIE_DOMAIN",
]);
if (
!sessionValid(
new StorageManager(SESSION_STORAGE_KEY),
publicEnvVariables.VITE_API_URL || "",
publicEnvVariables.VITE_COOKIE_DOMAIN || ""
)
)
return true;
return getSessionStale(new NamespacedStorageManager(SESSION_STORAGE_KEY));
sessionValid(
new StorageManager(SESSION_STORAGE_KEY),
publicEnvVariables.VITE_API_URL || "",
publicEnvVariables.VITE_COOKIE_DOMAIN || ""
);
const sessionIsStale = getSessionStale(
new NamespacedStorageManager(SESSION_STORAGE_KEY)
);
return sessionIsStale || defaultShouldRevalidate;
}

export function HydrateFallback() {
return <div style={{ padding: "32px" }}>Loading...</div>;
}
clientLoader.hydrate = true;

const adContainerIds = ["right-column-1", "right-column-2", "right-column-3"];

Expand Down
Loading