diff --git a/vue/src/components/RssFeeds.vue b/vue/src/components/RssFeeds.vue index acf8fea..51d6523 100644 --- a/vue/src/components/RssFeeds.vue +++ b/vue/src/components/RssFeeds.vue @@ -17,6 +17,7 @@ const { disconnectObserver, setInitialLoad, showMessageForXSeconds, + markCurrentArticleRead, } = useFeeds() const unreadCount = computed(() => feeds.value.filter(f => !f.read).length) @@ -122,6 +123,11 @@ onBeforeUnmount(() => { onMounted(async () => { setInitialLoad(false) await fetchData() + // viewMode persists across reloads (see useFeeds.js) — if we're booting + // straight into article view, the article now on screen needs the same + // immediate mark-read that toggleViewMode()/nextArticle()/prevArticle() + // give it when reached by in-session navigation. + if (viewMode.value === 'article') markCurrentArticleRead() sync(true) setTimeout(function () { setInitialLoad(true) diff --git a/vue/src/composables/__tests__/viewModeBoot.spec.js b/vue/src/composables/__tests__/viewModeBoot.spec.js index 4aedde5..de5a8f1 100644 --- a/vue/src/composables/__tests__/viewModeBoot.spec.js +++ b/vue/src/composables/__tests__/viewModeBoot.spec.js @@ -57,6 +57,10 @@ describe('viewMode boot persistence', () => { expect(wrapper.find('.article-single').exists()).toBe(true) expect(wrapper.find('#article').exists()).toBe(false) + // The article shown right after reload must be marked read immediately — + // not only once the user pages forward/back at least once. + expect(axios.put).toHaveBeenCalledWith('/api/v1/article/read/1', null, expect.anything()) + wrapper.unmount() }) diff --git a/vue/src/composables/useFeeds.js b/vue/src/composables/useFeeds.js index 49ffd2d..b81ddf3 100644 --- a/vue/src/composables/useFeeds.js +++ b/vue/src/composables/useFeeds.js @@ -593,6 +593,7 @@ export function useFeeds() { currentIndex, toggleViewMode, leaveArticleView, + markCurrentArticleRead, layout, toggleLayout, nextArticle,