fix: history heading shows when only index is cached

This commit is contained in:
Ayo 2023-06-15 08:43:41 +02:00
parent 7c949d6030
commit 9e2818004a

View file

@ -28,19 +28,18 @@ const {postDivSelector, skipSave = false} = Astro.props;
}
}
const cachedRequests = await cache.keys();
const list = document.querySelector('#post-list');
const cachedRequests = (await cache.keys())
.filter(request => {
const urlObj = new URL(request.url);
return urlObj.search !== '';
});
if(cachedRequests?.length) {
const list = document.querySelector('#post-list');
const heading = document.querySelector('#library span#heading') as HTMLHeadingElement;
heading.innerHTML = 'History';
cachedRequests
// temporary delete all cached errors
.filter(request => {
const urlObj = new URL(request.url);
return urlObj.search !== '';
})
.reverse()
.forEach(async (request) => {
const {url} = request;