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

Commit

Permalink
pwa much
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf Kaka committed Sep 15, 2023
1 parent 615306b commit ea3f42c
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 49 deletions.
1 change: 1 addition & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="manifest" href="/manifest.json" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Remy AI</title>
Expand Down
22 changes: 11 additions & 11 deletions frontend/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"name": "Remy the AI Chef Assistant",
"short_name": "Remy AI",
"icons": [
{
"src": "logo192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "logo512.png",
"sizes": "512x512",
"type": "image/png"
}
{
"src": "logo192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "logo512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
}
17 changes: 17 additions & 0 deletions frontend/public/offline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Remy AI Chef Assistant</title>
</head>
<body>
<div className="App">
<header className="App-header">
<img src="logo512.png" className="App-logo" alt="logo" />
<p>
Please go ONLINE
</p>
</header>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import Layout from "./pages/layout/Layout";
import NoPage from "./pages/NoPage";
import Chat from "./pages/chat/Chat";
import { AppStateProvider } from "./state/AppProvider";
import * as ServiceWorkerRegistration from "./serviceWorkerRegistration";

initializeIcons();

ServiceWorkerRegistration.unregister();

export default function App() {
return (
<AppStateProvider>
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/pages/chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,7 @@ const Chat = () => {
)}
{(appStateContext?.state.isChatHistoryOpen && appStateContext?.state.isCosmosDBAvailable?.status !== CosmosDBStatus.NotConfigured) && <ChatHistoryPanel />}
</Stack>
)
}
)}
<Stack horizontal className={styles.bottomNav}>
<Stack.Item className={styles.bottomNavButtonContainer}>
<IconButton
Expand Down
36 changes: 36 additions & 0 deletions frontend/src/service-worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export {};

const CACHE_NAME = "my-cache";

//install service worker
self.addEventListener("install", (event: any) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) =>
cache.addAll(["/", "/index.html", "/styles.css", "/app.js"])
)
);
});

//activate service worker
self.addEventListener("activate", (event: any) => {
event.waitUntil(
caches.keys().then((keyList) =>
Promise.all(
keyList.map((key) => {
if (key !== CACHE_NAME) {
return caches.delete(key);
}
})
)
)
);
});

//listen for requests
self.addEventListener("fetch", (event: any) => {
event.respondWith(
caches.match(event.request).then((response) => {
return response || fetch(event.request);
})
);
});
26 changes: 26 additions & 0 deletions frontend/src/serviceWorkerRegistration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export function register() {
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker
.register("/service-worker.js")
.then((registration) => {
console.log("Service worker registered:", registration);
})
.catch((error) => {
console.error("Service worker registration failed:", error);
});
});
}
}

export function unregister() {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready
.then((registration) => {
registration.unregister();
})
.catch((error) => {
console.error("Service worker unregistration failed:", error);
});
}
}
46 changes: 23 additions & 23 deletions static/assets/index-b1382f32.js → static/assets/index-58c579a4.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions static/assets/index-58c579a4.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion static/assets/index-b1382f32.js.map

This file was deleted.

3 changes: 2 additions & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="manifest" href="/manifest.json" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Remy AI</title>
<script type="module" crossorigin src="/assets/index-b1382f32.js"></script>
<script type="module" crossorigin src="/assets/index-58c579a4.js"></script>
<link rel="stylesheet" href="/assets/index-48efc6bf.css">
</head>
<body>
Expand Down
22 changes: 11 additions & 11 deletions static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"name": "Remy the AI Chef Assistant",
"short_name": "Remy AI",
"icons": [
{
"src": "logo192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "logo512.png",
"sizes": "512x512",
"type": "image/png"
}
{
"src": "logo192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "logo512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
}
17 changes: 17 additions & 0 deletions static/offline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Remy AI Chef Assistant</title>
</head>
<body>
<div className="App">
<header className="App-header">
<img src="logo512.png" className="App-logo" alt="logo" />
<p>
Please go ONLINE
</p>
</header>
</div>
</body>
</html>

0 comments on commit ea3f42c

Please sign in to comment.