parent
aaee1bc324
commit
cdcff88649
|
@ -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
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export default function (): void {
|
||||
navigator.serviceWorker.register("/service_worker.js", { scope: "/" });
|
||||
}
|
Loading…
Reference in New Issue