Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
feat: pwa use profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Nov 9, 2023
1 parent f40f473 commit f42a68c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export default function MyApp({
pageProps: { session, ...pageProps },
}) {
const router = useRouter();

if (typeof window !== "undefined" && window.localStorage) {
window.addEventListener("appinstalled", () => {
localStorage["installedFrom"] = window.location.pathname;
});
}

// Use the layout defined at the page level, if available
const getLayout =
Component.getLayout || ((page) => <MultiLayout>{page}</MultiLayout>);
Expand Down
13 changes: 13 additions & 0 deletions pages/pwa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useRouter } from "next/router";

export default function Pwa() {
const router = useRouter();
const installedFrom = localStorage["installedFrom"];
if (typeof window !== "undefined" && window.localStorage) {
if (installedFrom) {
router.push(`/${installedFrom}`);
} else {
router.push("/");
}
}
}
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"short_name": "biodrop",
"theme_color": "#FFFFFF",
"background_color": "#FFFFFF",
"start_url": ".",
"start_url": "/pwa",
"display": "standalone",
"orientation": "portrait",
"icons": [
Expand Down

0 comments on commit f42a68c

Please sign in to comment.