Skip to content

Commit 0e1ce25

Browse files
author
Saurabh Kumar Bajpai
committed
fix: code quality and safety improvements
1 parent af173a5 commit 0e1ce25

3 files changed

Lines changed: 3 additions & 24 deletions

File tree

‎frontend/js/chat.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ Tell me: what is stirring in you today?`,
854854
timestamp = rawMessage.timestamp;
855855
} else if (typeof rawMessage.timestamp === 'string') {
856856
const parsed = Date.parse(rawMessage.timestamp);
857-
if (!isNaN(parsed)) {
857+
if (!Number.isNaN(parsed)) {
858858
timestamp = parsed;
859859
}
860860
}

‎frontend/js/community-stories.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ document.addEventListener('DOMContentLoaded', () => {
4949
}
5050
];
5151

52-
let stories = JSON.parse(localStorage.getItem('bibliodrift_community_stories')) || defaultStories;
52+
let stories = (() => { try { return JSON.parse(localStorage.getItem('bibliodrift_community_stories')) } catch { return null } })() || defaultStories;
5353

5454
// Save to local storage
5555
const saveStories = () => {

‎sw.js/sw.js‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,4 @@ const ASSETS_TO_CACHE = [
1515
self.addEventListener('install', (event) => {
1616
event.waitUntil(
1717
caches.open(CACHE_NAME).then((cache) => {
18-
console.log('Caching essential UI sanctuary assets...');
19-
return cache.addAll(ASSETS_TO_CACHE);
20-
})
21-
);
22-
});
23-
24-
// Fetch Event: Cache-First strategy for core layout files
25-
self.addEventListener('fetch', (event) => {
26-
// Only intercept local GET requests
27-
if (event.request.method !== 'GET' || !event.request.url.startsWith(self.location.origin)) {
28-
return;
29-
}
30-
31-
event.respondWith(
32-
caches.match(event.request).then((cachedResponse) => {
33-
if (cachedResponse) {
34-
return cachedResponse; // Return local cache copy
35-
}
36-
return fetch(event.request); // Fallback to network
37-
})
38-
);
39-
});
18+
.catch(err => console.error(err))

0 commit comments

Comments
 (0)