Skip to content

Commit

Permalink
Merge pull request #181 from remix-pwa/patches
Browse files Browse the repository at this point in the history
Mini `client` patches
  • Loading branch information
ShafSpecs authored Apr 14, 2024
2 parents e9272b5 + ba2253b commit 3e311fa
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## @remix-pwa/client 3.0.1 (2024-04-14)


### Bug Fixes

* **client:** updated `updateAvailable` schematics 3b5f3f2
* **sw:** fixed linting + updated hook to reflect both updates & workers ea05e01

## @remix-pwa/client 3.0.1-dev.1 (2024-04-14)


Expand Down
10 changes: 7 additions & 3 deletions packages/client/hooks/usePWAManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,25 @@ export const usePWAManager = () => {
return;
}

registration.onupdatefound = () => {
const update = () => {
const newWorker = registration.installing;

if (newWorker) {
newWorker.onstatechange = () => {
const newSWUpdate = () => {
if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
setSwUpdate({ isUpdateAvailable: true, newWorker });
setUpdateAvailable(true);
}
};

newWorker.addEventListener('statechange', newSWUpdate);
}
};

registration.addEventListener('updatefound', update);

return () => {
registration.onupdatefound = null;
registration.removeEventListener('updatefound', update);
setSwUpdate(updateFalse);
setUpdateAvailable(false);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remix-pwa/client",
"version": "3.0.1-dev.1",
"version": "3.0.1",
"description": "A set of utilities for client-side development to enhance the native feel of your Remix App",
"repository": {
"type": "git",
Expand Down
7 changes: 7 additions & 0 deletions packages/sw/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## @remix-pwa/sw 3.0.2 (2024-04-14)


### Bug Fixes

* **sw:** re-pushing `sw` to nightly build 6586c68

## @remix-pwa/sw 3.0.2-dev.1 (2024-04-14)


Expand Down
2 changes: 1 addition & 1 deletion packages/sw/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remix-pwa/sw",
"version": "3.0.2-dev.1",
"version": "3.0.2",
"description": "Service Worker APIs and utilities for Remix PWA",
"repository": {
"type": "git",
Expand Down

0 comments on commit 3e311fa

Please sign in to comment.