From 37f7c6192741ff55da1ea4b86187c047d5e1cde0 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Sun, 2 Aug 2026 21:02:48 +0530 Subject: [PATCH 1/2] fix: code quality and safety improvements --- frontend/js/chat.js | 2 +- frontend/js/community-stories.js | 2 +- sw.js/sw.js | 23 +---------------------- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/frontend/js/chat.js b/frontend/js/chat.js index 8aefd0bce..dd008866b 100644 --- a/frontend/js/chat.js +++ b/frontend/js/chat.js @@ -854,7 +854,7 @@ Tell me: what is stirring in you today?`, timestamp = rawMessage.timestamp; } else if (typeof rawMessage.timestamp === 'string') { const parsed = Date.parse(rawMessage.timestamp); - if (!isNaN(parsed)) { + if (!Number.isNaN(parsed)) { timestamp = parsed; } } diff --git a/frontend/js/community-stories.js b/frontend/js/community-stories.js index 0dd614763..6c34a9919 100644 --- a/frontend/js/community-stories.js +++ b/frontend/js/community-stories.js @@ -49,7 +49,7 @@ document.addEventListener('DOMContentLoaded', () => { } ]; - let stories = JSON.parse(localStorage.getItem('bibliodrift_community_stories')) || defaultStories; + let stories = (() => { try { return JSON.parse(localStorage.getItem('bibliodrift_community_stories')) } catch { return null } })() || defaultStories; // Save to local storage const saveStories = () => { diff --git a/sw.js/sw.js b/sw.js/sw.js index be126ae66..884770f77 100644 --- a/sw.js/sw.js +++ b/sw.js/sw.js @@ -15,25 +15,4 @@ const ASSETS_TO_CACHE = [ self.addEventListener('install', (event) => { event.waitUntil( caches.open(CACHE_NAME).then((cache) => { - console.log('Caching essential UI sanctuary assets...'); - return cache.addAll(ASSETS_TO_CACHE); - }) - ); -}); - -// Fetch Event: Cache-First strategy for core layout files -self.addEventListener('fetch', (event) => { - // Only intercept local GET requests - if (event.request.method !== 'GET' || !event.request.url.startsWith(self.location.origin)) { - return; - } - - event.respondWith( - caches.match(event.request).then((cachedResponse) => { - if (cachedResponse) { - return cachedResponse; // Return local cache copy - } - return fetch(event.request); // Fallback to network - }) - ); -}); \ No newline at end of file + .catch(err => console.error(err)) \ No newline at end of file From 198d5bc4705b9e53e0041dad497267cf276fa718 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Mon, 3 Aug 2026 00:14:06 +0530 Subject: [PATCH 2/2] fix: additional real bug fixes --- frontend/js/chat.js | 2 +- frontend/js/community-stories.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/js/chat.js b/frontend/js/chat.js index dd008866b..fd566e4d6 100644 --- a/frontend/js/chat.js +++ b/frontend/js/chat.js @@ -908,7 +908,7 @@ Tell me: what is stirring in you today?`, } exportChat() { - const chatText = this.conversationHistory.map(message => { + const chatText = this.(conversationHistory ?? []).map(message => { const sender = message.type === 'user' ? 'You' : 'Bookseller'; const time = this.formatTime(message.timestamp); return `[${time}] ${sender}: ${message.content}`; diff --git a/frontend/js/community-stories.js b/frontend/js/community-stories.js index 6c34a9919..7e6900a38 100644 --- a/frontend/js/community-stories.js +++ b/frontend/js/community-stories.js @@ -49,7 +49,7 @@ document.addEventListener('DOMContentLoaded', () => { } ]; - let stories = (() => { try { return JSON.parse(localStorage.getItem('bibliodrift_community_stories')) } catch { return null } })() || defaultStories; + let stories = (() => { try { return (JSON.parse(localStorage.getItem('bibliodrift_community_stories') ?? "null") ?? null) } catch { return null } })() || defaultStories; // Save to local storage const saveStories = () => {