Add extra message to +error.svelte to handle, and clarify 'OFFLINE' error.
This commit is contained in:
@@ -251,7 +251,7 @@
|
||||
@media (min-width: 620px) {
|
||||
.cancel-row td,
|
||||
.delay-row td {
|
||||
font-size: 1.20rem;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export interface Preferences {
|
||||
const STORAGE_KEY = 'ob_pref';
|
||||
|
||||
const DEFAULT_PREFS: Preferences = {
|
||||
locationEnabled: false,
|
||||
locationEnabled: false
|
||||
};
|
||||
|
||||
function loadPrefs(): Preferences {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<img class="err-img" src={noResult} alt="" role="presentation" width="200" height="200" />
|
||||
{:else if page.status == 499}
|
||||
<!-- Change to a GSM-R X Sign?? -->
|
||||
<span>OFFLINE!</span>
|
||||
<img class="err-img" src={stopErr} alt="" role="presentation" width="150" height="210" />
|
||||
{:else}
|
||||
<!-- STOP Error image -->
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
if (browser && 'serviceWorker' in navigator) {
|
||||
try {
|
||||
const registration = await navigator.serviceWorker.register('/service-worker.js', {
|
||||
type: 'module',
|
||||
type: 'module'
|
||||
});
|
||||
console.info('OwlBoard Service Worker registered', registration.scope);
|
||||
} catch (error) {
|
||||
console.error('Service Worker installation failed: ', error)
|
||||
console.error('Service Worker installation failed: ', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -8,18 +8,13 @@ const sw = self as unknown as ServiceWorkerGlobalScope;
|
||||
const CACHE_NAME = `owlboard-cache-${version}`;
|
||||
const ASSETS = [
|
||||
...build,
|
||||
...files.filter(file =>
|
||||
!file.endsWith('manifest.json') &&
|
||||
!file.startsWith('/icons/')
|
||||
),
|
||||
'/',
|
||||
...files.filter((file) => !file.endsWith('manifest.json') && !file.startsWith('/icons/')),
|
||||
'/'
|
||||
];
|
||||
|
||||
sw.addEventListener('install', (event) => {
|
||||
sw.skipWaiting();
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS))
|
||||
);
|
||||
event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS)));
|
||||
});
|
||||
|
||||
sw.addEventListener('activate', (event) => {
|
||||
@@ -49,9 +44,7 @@ sw.addEventListener('fetch', (event) => {
|
||||
|
||||
// 1. Static Assets (Cache-First)
|
||||
if (ASSETS.includes(url.pathname) || url.pathname.startsWith('/_app/')) {
|
||||
event.respondWith(
|
||||
caches.match(request).then((res) => res || fetch(request))
|
||||
);
|
||||
event.respondWith(caches.match(request).then((res) => res || fetch(request)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,18 +54,15 @@ sw.addEventListener('fetch', (event) => {
|
||||
fetch(request).catch(() => {
|
||||
const errorObject: ApiEnvelope.Envelope = {
|
||||
e: {
|
||||
code: "NETWORK_DISCONNECTED",
|
||||
msg: "Cannot connect to the OwlBoard server"
|
||||
code: 'NETWORK_DISCONNECTED',
|
||||
msg: 'Cannot connect to the OwlBoard server'
|
||||
},
|
||||
t: Math.floor(Date.now() / 1000)
|
||||
};
|
||||
return new Response(
|
||||
JSON.stringify(errorObject),
|
||||
{
|
||||
return new Response(JSON.stringify(errorObject), {
|
||||
status: 503,
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user