mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Prefer arrow functions and callbacks (#1210)
This commit is contained in:
parent
33fe223b5d
commit
c427aa3cce
64 changed files with 784 additions and 847 deletions
|
@ -25,7 +25,7 @@ type Config = {
|
|||
onUpdate?: (registration: ServiceWorkerRegistration) => void;
|
||||
};
|
||||
|
||||
export function register(config?: Config) {
|
||||
export const register = (config?: Config) => {
|
||||
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
|
||||
// The URL constructor is available in all browsers that support SW.
|
||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
||||
|
@ -57,9 +57,9 @@ export function register(config?: Config) {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function registerValidSW(swUrl: string, config?: Config) {
|
||||
const registerValidSW = (swUrl: string, config?: Config) => {
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then((registration) => {
|
||||
|
@ -103,9 +103,9 @@ function registerValidSW(swUrl: string, config?: Config) {
|
|||
.catch((error) => {
|
||||
console.error("Error during service worker registration:", error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function checkValidServiceWorker(swUrl: string, config?: Config) {
|
||||
const checkValidServiceWorker = (swUrl: string, config?: Config) => {
|
||||
// Check if the service worker can be found. If it can't reload the page.
|
||||
fetch(swUrl, {
|
||||
headers: { "Service-Worker": "script" },
|
||||
|
@ -133,9 +133,9 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
|
|||
// "No internet connection found. App is running in offline mode.",
|
||||
// );
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export function unregister() {
|
||||
export const unregister = () => {
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.ready
|
||||
.then((registration) => {
|
||||
|
@ -145,4 +145,4 @@ export function unregister() {
|
|||
console.error(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue