this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: probably fix refresh thing

+34 -9
+34 -9
public/app.js
··· 117 117 // Update last refresh time 118 118 window.lastRefreshTime = Date.now(); 119 119 120 + // Keep a copy of the current stories for metrics calculation during loading 121 + const previousStories = allStories && allStories.length > 0 ? [...allStories] : null; 122 + 120 123 storyList.innerHTML = '<div class="loading">Loading stories...</div>'; 121 124 122 125 // Ensure live counters are running ··· 234 237 // Store all stories for filtering 235 238 allStories = data; 236 239 // Apply filters and update UI 237 - applyFiltersAndUpdateUI(); 240 + applyFiltersAndUpdateUI(previousStories); 238 241 } 239 242 }) 240 243 .catch((error) => { 241 - storyList.innerHTML = `<div class="loading">Error loading data: ${error.message}</div>`; 244 + // If there was an error but we have previous stories, keep showing them 245 + if (previousStories && previousStories.length > 0) { 246 + allStories = previousStories; 247 + applyFiltersAndUpdateUI(); 248 + } else { 249 + storyList.innerHTML = `<div class="loading">Error loading data: ${error.message}</div>`; 250 + } 242 251 console.error("Error fetching stories:", error); 243 252 }); 244 253 } 245 254 246 255 // Apply filters and update UI 247 - function applyFiltersAndUpdateUI() { 248 - if (!allStories || allStories.length === 0) return; 256 + function applyFiltersAndUpdateUI(fallbackStories = null) { 257 + // Use fallbackStories for metrics if current stories are empty 258 + const storiesForMetrics = (!allStories || allStories.length === 0) ? 259 + fallbackStories : allStories; 260 + 261 + if (!allStories || allStories.length === 0) { 262 + if (!fallbackStories) return; 263 + // If we have no current stories but have fallback, only update metrics 264 + updatePerformanceMetrics(fallbackStories); 265 + return; 266 + } 249 267 250 268 // Apply filters 251 269 let filteredStories = allStories; ··· 259 277 260 278 // Update UI with filtered stories 261 279 displayStories(filteredStories); 262 - updatePerformanceMetrics(allStories); // Always use all stories for this analysis 280 + updatePerformanceMetrics(storiesForMetrics); // Use appropriate stories for metrics 263 281 } 264 282 265 283 // Display stories in the UI ··· 540 558 // Update performance metrics 541 559 function updatePerformanceMetrics(stories) { 542 560 if (!stories || stories.length === 0) { 543 - // Only set these, total count is fetched separately 544 - topTenCountEl.textContent = "0"; 545 - mostActiveTimeEl.textContent = "N/A"; 546 - avgFrontpageTimeEl.textContent = "N/A"; 561 + // Don't reset values to zero if they already have values 562 + // This prevents flickering during refresh operations 563 + if (topTenCountEl.textContent === "0" || topTenCountEl.textContent === "") { 564 + topTenCountEl.textContent = "0"; 565 + } 566 + if (mostActiveTimeEl.textContent === "N/A" || mostActiveTimeEl.textContent === "") { 567 + mostActiveTimeEl.textContent = "N/A"; 568 + } 569 + if (avgFrontpageTimeEl.textContent === "N/A" || avgFrontpageTimeEl.textContent === "") { 570 + avgFrontpageTimeEl.textContent = "N/A"; 571 + } 547 572 return; 548 573 } 549 574