forked from trent_larson/crowd-funder-for-time-pwa
convert all remaining DB writes & reads to SQL (with successful registration & claim)
This commit is contained in:
@@ -3,17 +3,20 @@
|
||||
import { register } from "register-service-worker";
|
||||
|
||||
// Check if we're in an Electron environment
|
||||
const isElectron = process.env.VITE_PLATFORM === 'electron' ||
|
||||
process.env.VITE_DISABLE_PWA === 'true' ||
|
||||
window.navigator.userAgent.toLowerCase().includes('electron');
|
||||
const isElectron =
|
||||
process.env.VITE_PLATFORM === "electron" ||
|
||||
process.env.VITE_DISABLE_PWA === "true" ||
|
||||
window.navigator.userAgent.toLowerCase().includes("electron");
|
||||
|
||||
// Only register service worker if:
|
||||
// 1. Not in Electron
|
||||
// 2. PWA is explicitly enabled
|
||||
// 3. In production mode
|
||||
if (!isElectron &&
|
||||
process.env.VITE_PWA_ENABLED === "true" &&
|
||||
process.env.NODE_ENV === "production") {
|
||||
if (
|
||||
!isElectron &&
|
||||
process.env.VITE_PWA_ENABLED === "true" &&
|
||||
process.env.NODE_ENV === "production"
|
||||
) {
|
||||
register(`${process.env.BASE_URL}sw.js`, {
|
||||
ready() {
|
||||
console.log("Service worker is active.");
|
||||
@@ -42,11 +45,11 @@ if (!isElectron &&
|
||||
} else {
|
||||
console.log(
|
||||
`Service worker registration skipped - ${
|
||||
isElectron
|
||||
? "running in Electron"
|
||||
isElectron
|
||||
? "running in Electron"
|
||||
: process.env.VITE_PWA_ENABLED !== "true"
|
||||
? "PWA not enabled"
|
||||
: "not in production mode"
|
||||
}`
|
||||
}`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user