From 281c6fa2503e0a5f966468bdb9b60e7386f14104 Mon Sep 17 00:00:00 2001 From: Oksamies Date: Wed, 17 Sep 2025 19:43:07 +0300 Subject: [PATCH 1/2] Ensure current user is updated For some reason the localStorage set's in shouldRevalidate are not commited before the clientLoader is run. So run the sessionValid function in both, to ensure currentUser is updated. This does lead to some extra processing, but acceptable cost for now. --- apps/cyberstorm-remix/app/root.tsx | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/apps/cyberstorm-remix/app/root.tsx b/apps/cyberstorm-remix/app/root.tsx index ccd54f217..97a15f096 100644 --- a/apps/cyberstorm-remix/app/root.tsx +++ b/apps/cyberstorm-remix/app/root.tsx @@ -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 { @@ -158,22 +165,23 @@ 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; } +clientLoader.hydrate = true; + export function HydrateFallback() { return
Loading...
; } From 1d4ac3560856b9c1fe72f7df9b7c87c415cd5d0b Mon Sep 17 00:00:00 2001 From: Oksamies Date: Thu, 18 Sep 2025 20:27:25 +0300 Subject: [PATCH 2/2] Remove HydrateFallback from root Remove HydrateFallback from root to prevent the root loaders from holding back page specific skeleton loaders --- apps/cyberstorm-remix/app/root.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/cyberstorm-remix/app/root.tsx b/apps/cyberstorm-remix/app/root.tsx index 97a15f096..5cc7142ac 100644 --- a/apps/cyberstorm-remix/app/root.tsx +++ b/apps/cyberstorm-remix/app/root.tsx @@ -182,10 +182,6 @@ export function shouldRevalidate({ clientLoader.hydrate = true; -export function HydrateFallback() { - return
Loading...
; -} - const adContainerIds = ["right-column-1", "right-column-2", "right-column-3"]; export function Layout({ children }: { children: React.ReactNode }) {