Merge pull request #1107 from Retrospring/fix/pwa-installability

Fix PWA installability
This commit is contained in:
Karina Kwiatek 2023-02-26 23:48:05 +01:00 committed by GitHub
commit a33f7b23a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 8 additions and 3 deletions

View File

@ -1,10 +1,12 @@
import '@hotwired/turbo-rails';
import initializeBootstrap from './initializers/bootstrap';
import initializeServiceWorker from './initializers/serviceWorker';
import initializeStimulus from './initializers/stimulus';
export default function start(): void {
try {
initializeBootstrap();
initializeServiceWorker();
initializeStimulus();
} catch (e) {
// initialization errors

View File

@ -8,7 +8,7 @@ export function enableHandler (event: Event): void {
const sender = event.target as HTMLButtonElement;
try {
installServiceWorker()
getServiceWorker()
.then(subscribe)
.then(async subscription => {
return Notification.requestPermission().then(permission => {
@ -51,8 +51,8 @@ export function enableHandler (event: Event): void {
}
}
async function installServiceWorker(): Promise<ServiceWorkerRegistration> {
return navigator.serviceWorker.register("/service_worker.js", { scope: "/" });
async function getServiceWorker(): Promise<ServiceWorkerRegistration> {
return navigator.serviceWorker.getRegistration("/");
}
async function getServerKey(): Promise<Buffer> {

View File

@ -0,0 +1,3 @@
export default function (): void {
navigator.serviceWorker.register("/service_worker.js", { scope: "/" });
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 928 B