Skip to content

Commit

Permalink
feat: Enable automatic app reload (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
v-almonacid authored Mar 8, 2024
1 parent 7375231 commit 466d298
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BrowserTracing } from "@sentry/tracing";
import { createRoot } from "react-dom/client";
import { clarity } from "react-microsoft-clarity";
import { Provider } from "react-redux";
import { registerSW } from "virtual:pwa-register";
import { WagmiConfig } from "wagmi";
import { useIsMobile } from "./api/hooks/useIsMobile";
import { AppContextProvider } from "./api/store/providers/app-context-provider";
Expand All @@ -25,6 +26,14 @@ const App = lazyRetry(() => import("./App"));

setupIonicReact();

/**
* Enable automatic page reload.
* We adopted the `autoUpdate` behavior, but according to the workbox docs
* the app wouldn't reload unless we import at least one virtual module in the app code.
* See https://vite-pwa-org.netlify.app/guide/auto-update.html
*/
registerSW({ immediate: true });

/**
* at this point, the store is still not loaded and we can't read the state
* so we instead try to read local storage directly to retrieve users' cookie
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"./src/*",
"../ui-kit/src/*"
]
}
},
"types": [
"vite-plugin-pwa/client"
]
},
"include": [
"src/**/*",
Expand Down

0 comments on commit 466d298

Please sign in to comment.