Skip to content

Commit

Permalink
changed loading of pwa to script in app.html not onmount in layout an…
Browse files Browse the repository at this point in the history
…ymore
  • Loading branch information
liamk2103 committed Jul 23, 2022
1 parent 341254d commit 96122cb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,14 @@ TODO: add vercel deployment commands
To run Prettier, enter `npm run format`.

### GitHub Actions
### Common issues
The PWA can cause issues when developing, if you get
```
> listen EACCES: permission denied 127.0.0.1:3000
at Server.setupListenHandle [as _listen2] (node:net:1405:21)
at listenInCluster (node:net:1470:12)
at doListen (node:net:1609:7)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
```

Restart the Host Network Service (windows specific)
4 changes: 2 additions & 2 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
</head>
<body>
<div id="svelte">%sveltekit.body%</div>
<!-- <script>
<script>
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker.register("/service-worker.js").then((reg) => {
console.log("Service worker registered.", reg);
});
});
} -->
}
</script>
</body>
</html>
22 changes: 11 additions & 11 deletions src/routes/__layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
import Notifications from 'svelte-notifications';
import Deck from '../lib/Deck.svelte';
import { onMount } from 'svelte';
onMount(async () => {
// onMount(async () => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js', { scope: '/' }).then(function(reg) {
// registration worked
console.log('Registration succeeded. Scope is ' + reg.scope);
}).catch(function(error) {
// registration failed
console.log('Registration failed with ' + error);
});
};
// if ('serviceWorker' in navigator) {
// navigator.serviceWorker.register('/service-worker.js', { scope: '/' }).then(function(reg) {
// // registration worked
// console.log('Registration succeeded. Scope is ' + reg.scope);
// }).catch(function(error) {
// // registration failed
// console.log('Registration failed with ' + error);
// });
// };
});
// });
</script>

<Notifications>
Expand Down
2 changes: 1 addition & 1 deletion src/slides/demo/Slide10.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="bar-image slide-bar animate__animated animate__slideInRight animate__slow">
<img src="16.svg" alt="figure-1" class="w-70 mx-auto" />
<div class="flex flex-col">
<h2>Svelte-Slides is fluid</h2>
<h2>Preso is fluid</h2>
<p class="major">
Display your presentations on mobile or tablet. It is completely useless, but nice to have.
</p>
Expand Down

0 comments on commit 96122cb

Please sign in to comment.