refactor: Iterate through stories in order for prioritized updates

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-12-02 22:27:49 +00:00
parent bd85127613
commit 8d7d692d9c

View File

@@ -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') {