Fix feed feedback (#4730)
parent
4f02da96c8
commit
12bf796293
|
@ -6,11 +6,8 @@ import throttle from 'lodash.throttle'
|
||||||
import {PROD_DEFAULT_FEED} from '#/lib/constants'
|
import {PROD_DEFAULT_FEED} from '#/lib/constants'
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {
|
import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed'
|
||||||
FeedDescriptor,
|
import {getFeedPostSlice} from '#/view/com/posts/Feed'
|
||||||
FeedPostSliceItem,
|
|
||||||
isFeedPostSlice,
|
|
||||||
} from '#/state/queries/post-feed'
|
|
||||||
import {useAgent} from './session'
|
import {useAgent} from './session'
|
||||||
|
|
||||||
type StateContext = {
|
type StateContext = {
|
||||||
|
@ -93,11 +90,12 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
|
||||||
}, [enabled, sendToFeed])
|
}, [enabled, sendToFeed])
|
||||||
|
|
||||||
const onItemSeen = React.useCallback(
|
const onItemSeen = React.useCallback(
|
||||||
(slice: any) => {
|
(feedItem: any) => {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!isFeedPostSlice(slice)) {
|
const slice = getFeedPostSlice(feedItem)
|
||||||
|
if (slice === null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (const postItem of slice.items) {
|
for (const postItem of slice.items) {
|
||||||
|
|
|
@ -156,6 +156,14 @@ const interstials: Record<
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFeedPostSlice(feedItem: FeedItem): FeedPostSlice | null {
|
||||||
|
if (feedItem.type === 'slice') {
|
||||||
|
return feedItem.slice
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DISABLED need to check if this is causing random feed refreshes -prf
|
// DISABLED need to check if this is causing random feed refreshes -prf
|
||||||
// const REFRESH_AFTER = STALE.HOURS.ONE
|
// const REFRESH_AFTER = STALE.HOURS.ONE
|
||||||
const CHECK_LATEST_AFTER = STALE.SECONDS.THIRTY
|
const CHECK_LATEST_AFTER = STALE.SECONDS.THIRTY
|
||||||
|
|
Loading…
Reference in New Issue