diff --git a/src/state/feed-feedback.tsx b/src/state/feed-feedback.tsx index bb4292d9c6..e46728d58c 100644 --- a/src/state/feed-feedback.tsx +++ b/src/state/feed-feedback.tsx @@ -265,7 +265,7 @@ const m = Math.ceil((n * Math.log(p)) / Math.log(1 / Math.pow(2, Math.log(2)))) const k = Math.round((m / n) * Math.log(2)) let globalBloomFilter = new BloomFilter(m, k) -function markGloballySeenPost(uri: string) { +export function markGloballySeenPost(uri: string) { if (globalBloomFilter.size >= n) { // If we ever get here, just restart to avoid saturation. globalBloomFilter = new BloomFilter(m, k) diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index a0073b02f9..942cc37408 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -1,4 +1,4 @@ -import React, {memo, useRef, useState} from 'react' +import React, {memo, useEffect, useRef, useState} from 'react' import {StyleSheet, useWindowDimensions, View} from 'react-native' import {runOnJS} from 'react-native-reanimated' import Animated from 'react-native-reanimated' @@ -18,6 +18,7 @@ import {ScrollProvider} from '#/lib/ScrollContext' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {cleanError} from '#/lib/strings/errors' import {isAndroid, isNative, isWeb} from '#/platform/detection' +import {markGloballySeenPost} from '#/state/feed-feedback' import {useModerationOpts} from '#/state/preferences/moderation-opts' import { fillThreadModerationCache, @@ -391,6 +392,22 @@ export function PostThread({uri}: {uri: string | undefined}) { [refetch], ) + useEffect(() => { + if (skeleton) { + // We're not tracking linger time here so conservatively mark + // just the highlighted post and the parent. Presumably, + // if you're already midthread, you know what was above. + const {parents, highlightedPost} = skeleton + markGloballySeenPost(highlightedPost.uri) + for (let i = 0; i < parents.length; i++) { + const parent = parents[i] + if (isThreadPost(parent)) { + markGloballySeenPost(parent.uri) + } + } + } + }, [skeleton]) + const {openComposer} = useComposerControls() const onPressReply = React.useCallback(() => { if (thread?.type !== 'post') {