From e08858ba48e4d0737bc2c2838f12a8732831fa3e Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Fri, 13 Mar 2026 17:19:19 +0100 Subject: [PATCH] fix --- cache/prefetch/articles.json | 1 + cache/prefetch/articles.json.hdr | 1 + cache/prefetch/competition_aliases.json | 1 + cache/prefetch/competition_aliases.json.hdr | 1 + cache/prefetch/events_upcoming.json | 1 + cache/prefetch/events_upcoming.json.hdr | 1 + cache/prefetch/gallery.json | 1 + cache/prefetch/matches.json | 1 + cache/prefetch/meta.json | 1 + cache/prefetch/prefetch_status.json | 42 ++++++++++++++++ cache/prefetch/seo.json | 1 + cache/prefetch/seo.json.hdr | 1 + cache/prefetch/settings.json | 1 + cache/prefetch/settings.json.hdr | 1 + cache/prefetch/sponsors.json | 1 + cache/prefetch/sponsors.json.hdr | 1 + cache/prefetch/team_logo_overrides.json | 1 + cache/prefetch/team_logo_overrides.json.hdr | 1 + cache/prefetch/zonerama_flat.json | 1 + cache/prefetch/zonerama_flat.json.hdr | 4 ++ frontend/src/hooks/useFontLoader.ts | 13 +++-- frontend/src/serviceWorkerRegistration.ts | 53 +++++++++------------ 22 files changed, 96 insertions(+), 34 deletions(-) create mode 100644 cache/prefetch/articles.json create mode 100644 cache/prefetch/articles.json.hdr create mode 100644 cache/prefetch/competition_aliases.json create mode 100644 cache/prefetch/competition_aliases.json.hdr create mode 100644 cache/prefetch/events_upcoming.json create mode 100644 cache/prefetch/events_upcoming.json.hdr create mode 100644 cache/prefetch/gallery.json create mode 100644 cache/prefetch/matches.json create mode 100644 cache/prefetch/meta.json create mode 100644 cache/prefetch/prefetch_status.json create mode 100644 cache/prefetch/seo.json create mode 100644 cache/prefetch/seo.json.hdr create mode 100644 cache/prefetch/settings.json create mode 100644 cache/prefetch/settings.json.hdr create mode 100644 cache/prefetch/sponsors.json create mode 100644 cache/prefetch/sponsors.json.hdr create mode 100644 cache/prefetch/team_logo_overrides.json create mode 100644 cache/prefetch/team_logo_overrides.json.hdr create mode 100644 cache/prefetch/zonerama_flat.json create mode 100644 cache/prefetch/zonerama_flat.json.hdr diff --git a/cache/prefetch/articles.json b/cache/prefetch/articles.json new file mode 100644 index 0000000..b668362 --- /dev/null +++ b/cache/prefetch/articles.json @@ -0,0 +1 @@ +{"items":[],"page":1,"page_size":10,"total":0} \ No newline at end of file diff --git a/cache/prefetch/articles.json.hdr b/cache/prefetch/articles.json.hdr new file mode 100644 index 0000000..cad1982 --- /dev/null +++ b/cache/prefetch/articles.json.hdr @@ -0,0 +1 @@ +{"etag":"","fetched_at":"2026-03-13T16:17:10Z","last_modified":""} \ No newline at end of file diff --git a/cache/prefetch/competition_aliases.json b/cache/prefetch/competition_aliases.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/cache/prefetch/competition_aliases.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/cache/prefetch/competition_aliases.json.hdr b/cache/prefetch/competition_aliases.json.hdr new file mode 100644 index 0000000..cad1982 --- /dev/null +++ b/cache/prefetch/competition_aliases.json.hdr @@ -0,0 +1 @@ +{"etag":"","fetched_at":"2026-03-13T16:17:10Z","last_modified":""} \ No newline at end of file diff --git a/cache/prefetch/events_upcoming.json b/cache/prefetch/events_upcoming.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/cache/prefetch/events_upcoming.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/cache/prefetch/events_upcoming.json.hdr b/cache/prefetch/events_upcoming.json.hdr new file mode 100644 index 0000000..cad1982 --- /dev/null +++ b/cache/prefetch/events_upcoming.json.hdr @@ -0,0 +1 @@ +{"etag":"","fetched_at":"2026-03-13T16:17:10Z","last_modified":""} \ No newline at end of file diff --git a/cache/prefetch/gallery.json b/cache/prefetch/gallery.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/cache/prefetch/gallery.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/cache/prefetch/matches.json b/cache/prefetch/matches.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/cache/prefetch/matches.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/cache/prefetch/meta.json b/cache/prefetch/meta.json new file mode 100644 index 0000000..8bba2a7 --- /dev/null +++ b/cache/prefetch/meta.json @@ -0,0 +1 @@ +{"lastUpdated":"2026-03-13T16:17:10Z"} \ No newline at end of file diff --git a/cache/prefetch/prefetch_status.json b/cache/prefetch/prefetch_status.json new file mode 100644 index 0000000..8c6d205 --- /dev/null +++ b/cache/prefetch/prefetch_status.json @@ -0,0 +1,42 @@ +{ + "baseURL": "http://localhost:8080/api/v1", + "duration_ms": 94, + "endpoints": [ + { + "path": "/articles?page=1\u0026page_size=10\u0026published=true", + "file": "articles.json", + "ok": true + }, + { + "path": "/sponsors", + "file": "sponsors.json", + "ok": true + }, + { + "path": "/events/upcoming", + "file": "events_upcoming.json", + "ok": true + }, + { + "path": "/public/team-logo-overrides", + "file": "team_logo_overrides.json", + "ok": true + }, + { + "path": "/competition-aliases", + "file": "competition_aliases.json", + "ok": true + }, + { + "path": "/settings", + "file": "settings.json", + "ok": true + }, + { + "path": "/seo", + "file": "seo.json", + "ok": true + } + ], + "lastUpdated": "2026-03-13T16:17:10Z" +} \ No newline at end of file diff --git a/cache/prefetch/seo.json b/cache/prefetch/seo.json new file mode 100644 index 0000000..41c55c4 --- /dev/null +++ b/cache/prefetch/seo.json @@ -0,0 +1 @@ +{"additional_meta":"","canonical_base_url":"","default_og_image_url":"","enable_indexing":false,"meta_keywords":"","site_description":"","site_title":"","twitter_handle":""} \ No newline at end of file diff --git a/cache/prefetch/seo.json.hdr b/cache/prefetch/seo.json.hdr new file mode 100644 index 0000000..cad1982 --- /dev/null +++ b/cache/prefetch/seo.json.hdr @@ -0,0 +1 @@ +{"etag":"","fetched_at":"2026-03-13T16:17:10Z","last_modified":""} \ No newline at end of file diff --git a/cache/prefetch/settings.json b/cache/prefetch/settings.json new file mode 100644 index 0000000..4b97443 --- /dev/null +++ b/cache/prefetch/settings.json @@ -0,0 +1 @@ +{"about_html":"","accent_color":"#e53e3e","api_base_url":"","background_color":"#ffffff","club_data_mode":"auto","club_id":"","club_logo_url":"","club_name":"","club_type":"","club_url":"","contact_address":"","contact_city":"","contact_country":"","contact_email":"","contact_phone":"","contact_zip":"","custom_nav":null,"eshop_enabled":false,"facebook_url":"","font_body":"Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif","font_heading":"Poppins, sans-serif","frontend_base_url":"","gallery_label":"","gallery_url":"","instagram_url":"","location_latitude":0,"location_longitude":0,"map_style":"","map_zoom_level":0,"merch_items":null,"merch_limit":0,"merch_module_enabled":false,"merch_source":"","merch_style":"","premium":false,"primary_color":"#1a365d","secondary_color":"#2b6cb0","show_about_in_nav":false,"show_map_on_homepage":false,"sponsors_layout":"","sponsors_theme":"","text_color":"#1a202c","videos":null,"videos_items":null,"videos_limit":6,"videos_module_enabled":false,"videos_source":"auto","videos_style":"slider","videos_title_overrides":{},"youtube_url":""} \ No newline at end of file diff --git a/cache/prefetch/settings.json.hdr b/cache/prefetch/settings.json.hdr new file mode 100644 index 0000000..cad1982 --- /dev/null +++ b/cache/prefetch/settings.json.hdr @@ -0,0 +1 @@ +{"etag":"","fetched_at":"2026-03-13T16:17:10Z","last_modified":""} \ No newline at end of file diff --git a/cache/prefetch/sponsors.json b/cache/prefetch/sponsors.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/cache/prefetch/sponsors.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/cache/prefetch/sponsors.json.hdr b/cache/prefetch/sponsors.json.hdr new file mode 100644 index 0000000..cad1982 --- /dev/null +++ b/cache/prefetch/sponsors.json.hdr @@ -0,0 +1 @@ +{"etag":"","fetched_at":"2026-03-13T16:17:10Z","last_modified":""} \ No newline at end of file diff --git a/cache/prefetch/team_logo_overrides.json b/cache/prefetch/team_logo_overrides.json new file mode 100644 index 0000000..bf2195b --- /dev/null +++ b/cache/prefetch/team_logo_overrides.json @@ -0,0 +1 @@ +{"by_id":{},"by_name":{}} \ No newline at end of file diff --git a/cache/prefetch/team_logo_overrides.json.hdr b/cache/prefetch/team_logo_overrides.json.hdr new file mode 100644 index 0000000..cad1982 --- /dev/null +++ b/cache/prefetch/team_logo_overrides.json.hdr @@ -0,0 +1 @@ +{"etag":"","fetched_at":"2026-03-13T16:17:10Z","last_modified":""} \ No newline at end of file diff --git a/cache/prefetch/zonerama_flat.json b/cache/prefetch/zonerama_flat.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/cache/prefetch/zonerama_flat.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/cache/prefetch/zonerama_flat.json.hdr b/cache/prefetch/zonerama_flat.json.hdr new file mode 100644 index 0000000..93cd1f5 --- /dev/null +++ b/cache/prefetch/zonerama_flat.json.hdr @@ -0,0 +1,4 @@ +{ + "fetched_at": "2026-03-13T16:17:09Z", + "link": "" +} \ No newline at end of file diff --git a/frontend/src/hooks/useFontLoader.ts b/frontend/src/hooks/useFontLoader.ts index 83ea68b..c361857 100644 --- a/frontend/src/hooks/useFontLoader.ts +++ b/frontend/src/hooks/useFontLoader.ts @@ -1,6 +1,12 @@ import { useEffect } from 'react'; import { usePublicSettings } from './usePublicSettings'; -import { getFontPairing, applyFontPairing, getDefaultFontPairing } from '../config/fonts'; +import { + FONT_PAIRINGS, + getFontPairing, + applyFontPairing, + getDefaultFontPairing, + type FontPairing, +} from '../config/fonts'; /** * Hook to load and apply club fonts from settings @@ -12,15 +18,14 @@ export const useFontLoader = () => { // Determine which font pairing to use const fontId = settings?.font_heading || settings?.font_body; - let pairing; + let pairing: FontPairing | undefined; if (fontId) { // Try to find matching pairing by heading or body font name pairing = getFontPairing(fontId); // If not found by ID, try to find by font name if (!pairing) { - const allPairings = require('../config/fonts').FONT_PAIRINGS; - pairing = allPairings.find((p: any) => + pairing = FONT_PAIRINGS.find((p) => p.heading === fontId || p.body === fontId || p.id === fontId diff --git a/frontend/src/serviceWorkerRegistration.ts b/frontend/src/serviceWorkerRegistration.ts index 439e938..64b8f79 100644 --- a/frontend/src/serviceWorkerRegistration.ts +++ b/frontend/src/serviceWorkerRegistration.ts @@ -20,20 +20,37 @@ export function register(config?: Config) { } window.addEventListener('load', () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; - if (isLocalhost) { - checkValidServiceWorker(swUrl, config); - navigator.serviceWorker.ready.then(() => { - console.log('Service worker is ready in development mode'); - }); + disableLocalServiceWorkers(); + return; } else { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; registerValidSW(swUrl, config); } }); } } +function disableLocalServiceWorkers() { + navigator.serviceWorker + .getRegistrations() + .then(async (registrations) => { + await Promise.all(registrations.map((registration) => registration.unregister())); + + if ('caches' in window) { + const cacheKeys = await caches.keys(); + await Promise.all(cacheKeys.map((key) => caches.delete(key))); + } + + if (registrations.length > 0) { + console.log('Localhost detected; cleared service workers and caches.'); + } + }) + .catch((error) => { + console.error('Error while clearing localhost service workers:', error); + }); +} + function registerValidSW(swUrl: string, config?: Config) { navigator.serviceWorker .register(swUrl) @@ -68,30 +85,6 @@ function registerValidSW(swUrl: string, config?: Config) { }); } -function checkValidServiceWorker(swUrl: string, config?: Config) { - fetch(swUrl, { - headers: { 'Service-Worker': 'script' }, - }) - .then((response) => { - const contentType = response.headers.get('content-type'); - if ( - response.status === 404 || - (contentType != null && contentType.indexOf('javascript') === -1) - ) { - navigator.serviceWorker.ready.then((registration) => { - registration.unregister().then(() => { - window.location.reload(); - }); - }); - } else { - registerValidSW(swUrl, config); - } - }) - .catch(() => { - console.log('No internet connection found. App is running in offline mode.'); - }); -} - export function unregister() { if ('serviceWorker' in navigator) { navigator.serviceWorker.ready