-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from ZauberNerd/service-worker
Add service worker and make PWA installable
- Loading branch information
Showing
9 changed files
with
143 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,33 +3,24 @@ | |
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="dns-prefetch" href="https://fonts.googleapis.com"> | ||
<link rel="dns-prefetch" href="https://cdnjs.cloudflare.com"> | ||
<link rel="dns-prefetch" href="https://cdn.jsdelivr.net"> | ||
<link rel="preconnect" crossorigin="anonymous" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" crossorigin="anonymous" href="https://cdnjs.cloudflare.com"> | ||
<link rel="preconnect" crossorigin="anonymous" href="https://cdn.jsdelivr.net"> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<!-- mobile app viewport --> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta name="description" content="An open source ChatGPT app with a voice." /> | ||
<link rel="apple-touch-icon" href="/logo192.png" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="/manifest.json" /> | ||
<!-- | ||
Notice the use of in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>Chat with GPT | Unofficial ChatGPT app</title> | ||
<link rel="stylesheet" media="all" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" /> | ||
<link rel="stylesheet" media="all" href="https://fonts.googleapis.com/css?family=Open+Sans:100,400,300,500,700,800" /> | ||
<link rel="stylesheet" media="all" href="https://fonts.googleapis.com/css?family=Fira+Code:100,400,300,500,700,800" /> | ||
<link href="https://fonts.googleapis.com/css?family=Work+Sans:300,400,500,600,700&display=swap" rel="stylesheet"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" | ||
integrity="sha384-Xi8rHCmBmhbuyyhbI88391ZKP2dmfnOl4rT9ZfRI7mLTdk1wblIUnrIq35nqwEvC" crossorigin="anonymous"> | ||
<link rel="stylesheet" crossorigin="anonymous" media="all" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" /> | ||
<link rel="stylesheet" crossorigin="anonymous" media="all" href="https://fonts.googleapis.com/css?family=Open+Sans:100,400,300,500,700,800" /> | ||
<link rel="stylesheet" crossorigin="anonymous" media="all" href="https://fonts.googleapis.com/css?family=Fira+Code:100,400,300,500,700,800" /> | ||
<link rel="stylesheet" crossorigin="anonymous" href="https://fonts.googleapis.com/css?family=Work+Sans:300,400,500,600,700&display=swap"> | ||
<link rel="stylesheet" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-Xi8rHCmBmhbuyyhbI88391ZKP2dmfnOl4rT9ZfRI7mLTdk1wblIUnrIq35nqwEvC"> | ||
<link rel="stylesheet" href="/prose.css" /> | ||
<link rel="canonical" href="https://www.chatwithgpt.ai" /> | ||
<style> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Button, Notification } from "@mantine/core"; | ||
import { useCallback } from "react"; | ||
import { useRegisterSW } from "virtual:pwa-register/react"; | ||
|
||
export function InstallUpdateNotification() { | ||
const { | ||
offlineReady: [_, setOfflineReady], | ||
needRefresh: [needRefresh, setNeedRefresh], | ||
updateServiceWorker, | ||
} = useRegisterSW({ | ||
onRegistered(r) { | ||
console.log("SW Registered:", r); | ||
}, | ||
onRegisterError(error) { | ||
console.log("SW registration error", error); | ||
}, | ||
}); | ||
|
||
const onClose = () => { | ||
setOfflineReady(false); | ||
setNeedRefresh(false); | ||
}; | ||
|
||
const onUpdate = useCallback(async () => { | ||
updateServiceWorker(true); | ||
}, []); | ||
|
||
return needRefresh ? ( | ||
<Notification title="Update available!" onClose={onClose}> | ||
Click{" "} | ||
<Button compact onClick={onUpdate}> | ||
Update now | ||
</Button>{" "} | ||
to get the latest version. | ||
</Notification> | ||
) : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,4 +86,4 @@ async function bootstrapApplication() { | |
); | ||
} | ||
|
||
bootstrapApplication(); | ||
bootstrapApplication(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/// <reference types="vite-plugin-comlink/client" /> | ||
/// <reference types="vite-plugin-pwa/client" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters