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

Improvement #29

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,992 changes: 3,992 additions & 0 deletions .castor.stub.php

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
/assets/vendor/
###< symfony/asset-mapper ###

/public/favicon.ico
/public/favicons
/public/workbox
/public/site.webmanifest
/public/site.*.webmanifest
/public/pwa
/public/favicon.ico
/public/sw.js

###> liip/imagine-bundle ###
/public/media/cache/
###< liip/imagine-bundle ###
52 changes: 46 additions & 6 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,61 @@
{
"controllers": {
"@spomky-labs/pwa-bundle": {
"backgroundsync-form": {
"enabled": true,
"fetch": "eager"
},
"badge": {
"enabled": true,
"fetch": "eager"
},
"battery": {
"enabled": true,
"fetch": "eager"
},
"connection-status": {
"enabled": true,
"fetch": "lazy"
"fetch": "eager"
},
"backgroundsync-form": {
"device-orientation": {
"enabled": true,
"fetch": "lazy"
"fetch": "eager"
},
"sync-broadcast": {
"fullscreen": {
"enabled": true,
"fetch": "eager"
},
"geolocation": {
"enabled": true,
"fetch": "eager"
},
"install": {
"enabled": true,
"fetch": "lazy"
"fetch": "eager"
},
"prefetch-on-demand": {
"enabled": true,
"fetch": "lazy"
"fetch": "eager"
},
"presentation": {
"enabled": true,
"fetch": "eager"
},
"receiver": {
"enabled": true,
"fetch": "eager"
},
"share": {
"enabled": true,
"fetch": "eager"
},
"sync-broadcast": {
"enabled": true,
"fetch": "eager"
},
"vibration": {
"enabled": true,
"fetch": "eager"
}
}
},
Expand Down
13 changes: 0 additions & 13 deletions assets/controllers/items_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,12 @@ export default class extends Controller {
// this endpoint will return CORS error
const response = await fetch(this.collectionUrlValue);
if (!response.ok) {
throw new Error("Network response was not OK");
this.errorTarget.innerHTML = 'unable to fetch items at this time.';
console.error('Failed');
return;
} else {
// promise resolved.
const items = await response.json();
const count = items['hydra:totalItems'];
this.messageTarget.innerHTML = `${count} total items`;

this.listTarget.innerHTML = '<ol>'
for (const item of items['hydra:member']) {
// this.listTarget.innerHTML += `<li>${item.name}</li>`;
console.log(item);
}
this.listTarget.innerHTML += `</ol>`;

console.log(items);

}
} catch {
this.messageTarget.innerHTML = 'unable to fetch items at this time.';
Expand Down
15 changes: 0 additions & 15 deletions assets/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,3 @@
You can define here custom rules depending on your application needs.
*/
console.log('Service Worker Loaded...');

addEventListener("backgroundfetchsuccess", (event) => {
const registration = event.registration;
event.waitUntil(async () => {
const cache = await caches.open("movies");
const records = await registration.matchAll();
const cachePromises = records.map(async (record) => {
const response = await record.responseReady;
await cache.put(record.request, response);
});

await Promise.all(cachePromises);
event.updateUI({ title: "Move download complete" });
});
});
Loading
Loading