Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo: service worker for offline access #41

Merged
merged 4 commits into from
Aug 2, 2023

Conversation

divdavem
Copy link
Member

@divdavem divdavem commented Aug 1, 2023

No description provided.

@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #41 (e36e1f1) into main (e419c85) will decrease coverage by 9.59%.
Report is 1 commits behind head on main.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main      #41      +/-   ##
==========================================
- Coverage   93.08%   83.49%   -9.59%     
==========================================
  Files          21       60      +39     
  Lines         680     1818    +1138     
  Branches      123      361     +238     
==========================================
+ Hits          633     1518     +885     
- Misses         28      251     +223     
- Partials       19       49      +30     
Flag Coverage Δ
e2e-1 70.57% <ø> (?)
e2e-10 77.11% <ø> (?)
e2e-2 81.91% <ø> (?)
e2e-3 81.91% <ø> (?)
e2e-4 52.33% <ø> (?)
e2e-5 80.41% <ø> (?)
e2e-6 80.41% <ø> (?)
e2e-7 73.23% <ø> (?)
e2e-8 77.01% <ø> (?)
e2e-9 66.18% <ø> (?)
unit 93.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 57 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@divdavem divdavem marked this pull request as ready for review August 1, 2023 09:39
event.waitUntil(
(async () => {
await self.clients.claim();
for (const key of await caches.keys()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If caches allows it, you could delete all deprecated caches in parallel:

await Promise.all((await caches.keys()).filter((key) => key !== CACHE).map((key) => caches.delete(key)));

});
for (const file of files) {
const name = path.posix.join(dst, file);
console.log(name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use instead a logger created using vite createLogger utility.

const cache = await caches.open(CACHE);
const {withHash, withoutHash} = splitAssets(ASSETS);
const missingWithHash: string[] = [];
for (const url of withHash) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe could be written as the following:

await Promise.all(
	withHash.map((url) =>
		caches.match(url).then((response) => {
			if (response?.ok) {
				cache.put(url, response);
			} else {
				missingWithHash.push(url);
			}
		})
	)
);

Not sure of the gain however.

@divdavem
Copy link
Member Author

divdavem commented Aug 2, 2023

@quentinderoubaix Thank you for your good suggestions. I have added commit e36e1f1 to implement these changes.

Copy link
Contributor

@quentinderoubaix quentinderoubaix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@divdavem
Copy link
Member Author

divdavem commented Aug 2, 2023

@quentinderoubaix Thank you for your review!

@quentinderoubaix quentinderoubaix merged commit 44cc849 into AmadeusITGroup:main Aug 2, 2023
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants