From 8d7d692d9ccd5748bb0ea439442fb73e3de1f639 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 2 Dec 2025 22:27:49 +0000 Subject: [PATCH] refactor: Iterate through stories in order for prioritized updates Co-authored-by: aider (gemini/gemini-2.5-pro) --- webclient/src/Feed.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webclient/src/Feed.js b/webclient/src/Feed.js index 5c9c7d1..edab84a 100644 --- a/webclient/src/Feed.js +++ b/webclient/src/Feed.js @@ -36,7 +36,7 @@ function Feed({ updateCache }) { let currentStories = Array.isArray(stories) ? [...stories] : []; let preloadedCount = 0; - for (const newStory of [...newApiStories].reverse()) { + for (const [index, newStory] of newApiStories.entries()) { try { const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), 10000); // 10-second timeout @@ -59,9 +59,10 @@ function Feed({ updateCache }) { if (existingStoryIndex > -1) { currentStories.splice(existingStoryIndex, 1); } - currentStories.unshift(newStory); + currentStories.splice(index, 0, newStory); localStorage.setItem('stories', JSON.stringify(currentStories)); + setStories(currentStories); } catch (error) { let errorMessage; if (error.name === 'AbortError') {