Skip to content

Commit

Permalink
fix: try something
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Fontanier committed Dec 19, 2023
1 parent fcf5a7d commit f4e495b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions front/iosSafariAutoscrollBack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default function enable() {
const ua = window.navigator.userAgent;
const iOS = !!ua.match(/iPad/i) || !!ua.match(/iPhone/i);
const webkit = !!ua.match(/WebKit/i);
const iOSSafari = iOS && webkit && !ua.match(/CriOS/i);

if (iOSSafari) {
window.alert(
"You are using iOS Safari. Please use Chrome or Firefox for the best experience."
);
}
}
2 changes: 2 additions & 0 deletions front/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SessionProvider } from "next-auth/react";
import { MouseEvent, ReactNode } from "react";

import { NotificationArea } from "@app/components/sparkle/Notification";
import enableSafariAutoscrollBack from "@app/iosSafariAutoscrollBack";

function NextLinkWrapper({
href,
Expand Down Expand Up @@ -48,6 +49,7 @@ export default function App({
Component,
pageProps: { session, ...pageProps },
}: AppProps) {
enableSafariAutoscrollBack();
return (
<SparkleContext.Provider value={{ components: { link: NextLinkWrapper } }}>
<SessionProvider session={session}>
Expand Down

0 comments on commit f4e495b

Please sign in to comment.