Skip to content

Commit

Permalink
Merge pull request #230 from tarunkumar2005/offline-status
Browse files Browse the repository at this point in the history
Offline First Experience with Caching and Sync Status Indicator
  • Loading branch information
jahnvisahni31 authored Nov 1, 2024
2 parents 9d1ad07 + df87107 commit 9d4e138
Show file tree
Hide file tree
Showing 6 changed files with 3,785 additions and 111 deletions.
1 change: 0 additions & 1 deletion app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function App() {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [darkMode, setDarkMode] = useState(false);


const icons = {
chevron: <ChevronDown fill="currentColor" size={16} className="some-class-name" height={undefined} width={undefined} />,
hammer: <ImHammer />,
Expand Down
17 changes: 17 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import type { Metadata } from "next";
import { Work_Sans } from "next/font/google";
import "./globals.css";
Expand All @@ -6,6 +8,7 @@ import ThemeProvider from "./provider";
import ThemeSwitcher from "@/components/ui/ThemeSwitcher";
import { UserProvider } from "@/context/UserContext";
import AnimatedCursor from "react-animated-cursor";
import { useEffect } from 'react';
const workSans = Work_Sans({
subsets: ["latin"],
variable: "--font-work-sans",
Expand All @@ -22,6 +25,20 @@ export default function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
useEffect(() => {
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js')
.then((registration) => {
console.log('ServiceWorker registration successful:', registration);
})
.catch((err) => {
console.log('ServiceWorker registration failed:', err);
});
});
}
}, []);

return (
<html lang="en">
<body className={`${workSans.className} bg-dark`}>
Expand Down
Loading

0 comments on commit 9d4e138

Please sign in to comment.