Merge branch 'service-worker-bust' into staging_environment

This commit is contained in:
Carter 2025-08-21 15:23:53 -06:00
commit 792eea73bf
5 changed files with 46 additions and 3 deletions

View file

@ -71,6 +71,12 @@ http {
add_header Cache-Control "no-store, no-cache, must-revalidate"; add_header Cache-Control "no-store, no-cache, must-revalidate";
} }
# Force re-cache of old service-worker
location = /service-worker.js {
root /usr/share/nginx/html; # adjust if your build folder is elsewhere
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
# Redirect old /index.html requests to new file # Redirect old /index.html requests to new file
location = /index.html { location = /index.html {
return 301 /indexV2.html; return 301 /indexV2.html;

2
package-lock.json generated
View file

@ -42,7 +42,7 @@
"mui-tel-input": "^7.0.0", "mui-tel-input": "^7.0.0",
"notistack": "^3.0.1", "notistack": "^3.0.1",
"openweathermap-ts": "^1.2.10", "openweathermap-ts": "^1.2.10",
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging", "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master",
"query-string": "^9.2.1", "query-string": "^9.2.1",
"react": "^18.3.1", "react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1", "react-beautiful-dnd": "^13.1.1",

View file

@ -54,7 +54,7 @@
"mui-tel-input": "^7.0.0", "mui-tel-input": "^7.0.0",
"notistack": "^3.0.1", "notistack": "^3.0.1",
"openweathermap-ts": "^1.2.10", "openweathermap-ts": "^1.2.10",
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging", "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master",
"query-string": "^9.2.1", "query-string": "^9.2.1",
"react": "^18.3.1", "react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1", "react-beautiful-dnd": "^13.1.1",

24
public/service-worker.js Normal file
View file

@ -0,0 +1,24 @@
// public/service-worker.js
self.addEventListener('install', () => self.skipWaiting());
self.addEventListener('activate', async () => {
// Unregister old CRA SW
const regs = await self.registration.scope ? [self.registration] : await self.clients.getRegistrations();
for (const reg of regs) {
if (reg && reg.scriptURL.endsWith('service-worker.js')) {
await reg.unregister();
}
}
// Clear all caches
if ('caches' in self) {
const keys = await caches.keys();
for (const key of keys) {
await caches.delete(key);
}
}
// Reload all clients
const clients = await self.clients.matchAll({ type: 'window' });
clients.forEach(client => client.navigate(client.url));
});

View file

@ -82,7 +82,20 @@ export default function UserWrapper(props: Props) {
firmware: new Map() firmware: new Map()
}) })
}).catch(() => { }).catch(() => {
setGlobal(globalDefault) userAPI.getUser(user_id).then(user => {
setGlobal({
user: user ? user : User.create(),
team: globalDefault.team,
as: "",
showErrors: false,
userTeamPermissions: [],
backgroundTasksComplete: false,
firmware: new Map()
})
}).catch(() => {
setGlobal(globalDefault)
})
}) })
.finally(() => { .finally(() => {
setLoading(false) setLoading(false)