From 031627d65aa7fefd372c89bb45b014cfc515ade6 Mon Sep 17 00:00:00 2001 From: Misode Date: Fri, 28 May 2021 03:09:52 +0200 Subject: [PATCH] More debugging --- src/app/DataFetcher.ts | 4 ++++ src/app/Router.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/app/DataFetcher.ts b/src/app/DataFetcher.ts index 6a825b62..35bd36c1 100644 --- a/src/app/DataFetcher.ts +++ b/src/app/DataFetcher.ts @@ -51,7 +51,9 @@ export async function fetchData(target: CollectionRegistry, versionId: string) { .map(async r => { console.debug(`[deleteMatching] ${r.id} '${localStorage.getItem(`cached_${r.id}`)}' < '${r.hash}' ${r.url}/${version.refs[r.id]}`) await deleteMatching(url => url.startsWith(`${r.url}/${version.refs[r.id]}`)) + console.debug(`[deleteMatching] Done! ${r.id} ${r.hash} '${localStorage.getItem(`cached_${r.id}`)}'`) localStorage.setItem(`cached_${r.id}`, r.hash) + console.debug(`[deleteMatching] Set! ${r.id} ${r.hash} '${localStorage.getItem(`cached_${r.id}`)}'`) })) } @@ -176,11 +178,13 @@ async function getData(url: string, fn: (v: any) => T = (v: any) => v): async function deleteMatching(matches: (url: string) => boolean) { const cache = await caches.open(CACHE_NAME) const promises: Promise[] = [] + console.debug(`[deleteMatching] ${CACHE_NAME} ${cache}`) for (const request of await cache.keys()) { if (matches(request.url)) { promises.push(cache.delete(request)) } } + console.debug(`[deleteMatching] ${CACHE_NAME} ${promises.length}`) return (await Promise.all(promises)).length > 0 } diff --git a/src/app/Router.ts b/src/app/Router.ts index b37c0381..75cf236f 100644 --- a/src/app/Router.ts +++ b/src/app/Router.ts @@ -11,9 +11,13 @@ import config from '../config.json' const categories = config.models.filter(m => m.category === true) const router = async () => { + localStorage.length + const urlParts = location.pathname.split('/').filter(e => e) const urlParams = new URLSearchParams(location.search) console.debug(`[router] ${urlParts.join('/')}`) + console.debug(`[router] LocalStorage? ${'localStorage' in window}`) + console.debug(`[router] Caches? ${'caches' in window}`) const target = document.getElementById('app')! let title = locale('title.home')