From cd576fff82af51d037c244e828d4e5affd5ca146 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Fri, 28 Feb 2025 17:16:13 +0800 Subject: [PATCH] fix(mobile): no marking read when no scrolling (#2913) --- apps/mobile/src/modules/entry-list/hooks.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/mobile/src/modules/entry-list/hooks.ts b/apps/mobile/src/modules/entry-list/hooks.ts index 379c799e3..cd8c11586 100644 --- a/apps/mobile/src/modules/entry-list/hooks.ts +++ b/apps/mobile/src/modules/entry-list/hooks.ts @@ -12,7 +12,7 @@ export function useOnViewableItemsChanged({ }: { idExtractor?: (item: ViewToken) => string } = {}) { - const orientation = useRef<"down" | "up">("down") + const orientation = useRef<"down" | "up" | "initial">("initial") const lastOffset = useRef(0) const markAsReadWhenScrolling = useGeneralSettingKey("scrollMarkUnread") @@ -26,7 +26,9 @@ export function useOnViewableItemsChanged({ }) => void = useNonReactiveCallback(({ viewableItems, changed }) => { debouncedFetchEntryContentByStream(viewableItems.map((item) => stableIdExtractor(item))) - if (markAsReadWhenScrolling && orientation.current === "down") { + if (orientation.current !== "down") return + + if (markAsReadWhenScrolling) { changed .filter((item) => !item.isViewable) .forEach((item) => { @@ -34,7 +36,7 @@ export function useOnViewableItemsChanged({ }) } - if (markAsReadWhenRendering && orientation.current === "down") { + if (markAsReadWhenRendering) { viewableItems.forEach((item) => { unreadSyncService.markEntryAsRead(stableIdExtractor(item)) })