diff --git a/webclient/src/Feed.js b/webclient/src/Feed.js index 90ef3d9..1e12d69 100644 --- a/webclient/src/Feed.js +++ b/webclient/src/Feed.js @@ -21,13 +21,8 @@ function Feed({ updateCache }) { if (!updated) return; let currentStories = Array.isArray(stories) ? [...stories] : []; - const existingStoryIds = new Set(currentStories.map(s => s.id)); for (const newStory of [...newApiStories].reverse()) { - if (existingStoryIds.has(newStory.id)) { - continue; - } - try { const storyRes = await fetch('/api/' + newStory.id); if (!storyRes.ok) throw new Error('Story fetch failed'); @@ -38,6 +33,10 @@ function Feed({ updateCache }) { console.log('Preloaded story:', fullStory.id, fullStory.title); updateCache(fullStory.id, fullStory); + const existingStoryIndex = currentStories.findIndex(s => s.id === newStory.id); + if (existingStoryIndex > -1) { + currentStories.splice(existingStoryIndex, 1); + } currentStories.unshift(newStory); } catch (error) { console.log('Skipping story due to fetch error', newStory.id, error);