FeedFeedback fixes (#3968)

* Lower seen threshold to 1.5s

* Send feedContext for replies

* Use a simpler and more reliable feedContext fallback

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
zio/stable
dan 2024-05-12 18:30:00 +01:00 committed by GitHub
parent 97750c4aab
commit 4458b03173
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 3 deletions

View File

@ -71,6 +71,10 @@ export class FeedViewPostsSlice {
?.__source as ReasonFeedSource ?.__source as ReasonFeedSource
} }
get feedContext() {
return this.items.find(item => item.feedContext)?.feedContext
}
containsUri(uri: string) { containsUri(uri: string) {
return !!this.items.find(item => item.post.uri === uri) return !!this.items.find(item => item.post.uri === uri)
} }

View File

@ -303,7 +303,7 @@ export function usePostFeedQuery(
i === 0 && slice.source i === 0 && slice.source
? slice.source ? slice.source
: item.reason, : item.reason,
feedContext: item.feedContext, feedContext: item.feedContext || slice.feedContext,
moderation: moderations[i], moderation: moderations[i],
} }
} }

View File

@ -90,7 +90,7 @@ function ListImpl<ItemT>(
}, },
{ {
itemVisiblePercentThreshold: 40, itemVisiblePercentThreshold: 40,
minimumViewTime: 2e3, minimumViewTime: 1.5e3,
}, },
] ]
}, [onItemSeen]) }, [onItemSeen])

View File

@ -27,7 +27,7 @@ export type ListProps<ItemT> = Omit<
} }
export type ListRef = React.MutableRefObject<any | null> // TODO: Better types. export type ListRef = React.MutableRefObject<any | null> // TODO: Better types.
const ON_ITEM_SEEN_WAIT_DURATION = 2e3 // post must be "seen" 2 seconds before capturing const ON_ITEM_SEEN_WAIT_DURATION = 1.5e3 // when we consider post to be "seen"
const ON_ITEM_SEEN_INTERSECTION_OPTS = { const ON_ITEM_SEEN_INTERSECTION_OPTS = {
rootMargin: '-200px 0px -200px 0px', rootMargin: '-200px 0px -200px 0px',
} // post must be 200px visible to be "seen" } // post must be 200px visible to be "seen"