Remove unused NoopFeedTuner (#4856)

zio/stable
dan 2024-07-31 13:00:22 +01:00 committed by GitHub
parent c3e77b56ff
commit c75bb65bef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 31 deletions

View File

@ -136,16 +136,6 @@ export class FeedViewPostsSlice {
} }
} }
export class NoopFeedTuner {
reset() {}
tune(
feed: FeedViewPost[],
_opts?: {dryRun: boolean; maintainOrder: boolean},
): FeedViewPostsSlice[] {
return feed.map(item => new FeedViewPostsSlice(item))
}
}
export class FeedTuner { export class FeedTuner {
seenKeys: Set<string> = new Set() seenKeys: Set<string> = new Set()
seenUris: Set<string> = new Set() seenUris: Set<string> = new Set()

View File

@ -31,7 +31,7 @@ import {LikesFeedAPI} from 'lib/api/feed/likes'
import {ListFeedAPI} from 'lib/api/feed/list' import {ListFeedAPI} from 'lib/api/feed/list'
import {MergeFeedAPI} from 'lib/api/feed/merge' import {MergeFeedAPI} from 'lib/api/feed/merge'
import {FeedAPI, ReasonFeedSource} from 'lib/api/feed/types' import {FeedAPI, ReasonFeedSource} from 'lib/api/feed/types'
import {FeedTuner, FeedTunerFn, NoopFeedTuner} from 'lib/api/feed-manip' import {FeedTuner, FeedTunerFn} from 'lib/api/feed-manip'
import {BSKY_FEED_OWNER_DIDS} from 'lib/constants' import {BSKY_FEED_OWNER_DIDS} from 'lib/constants'
import {KnownError} from '#/view/com/posts/FeedErrorMessage' import {KnownError} from '#/view/com/posts/FeedErrorMessage'
import {useFeedTuners} from '../preferences/feed-tuners' import {useFeedTuners} from '../preferences/feed-tuners'
@ -61,7 +61,6 @@ export type FeedDescriptor =
| `list|${ListUri}` | `list|${ListUri}`
| `list|${ListUri}|${ListFilter}` | `list|${ListUri}|${ListFilter}`
export interface FeedParams { export interface FeedParams {
disableTuner?: boolean
mergeFeedEnabled?: boolean mergeFeedEnabled?: boolean
mergeFeedSources?: string[] mergeFeedSources?: string[]
} }
@ -105,7 +104,7 @@ export interface FeedPageUnselected {
export interface FeedPage { export interface FeedPage {
api: FeedAPI api: FeedAPI
tuner: FeedTuner | NoopFeedTuner tuner: FeedTuner
cursor: string | undefined cursor: string | undefined
slices: FeedPostSlice[] slices: FeedPostSlice[]
fetchedAt: number fetchedAt: number
@ -142,18 +141,11 @@ export function usePostFeedQuery(
const selectArgs = React.useMemo( const selectArgs = React.useMemo(
() => ({ () => ({
feedTuners, feedTuners,
disableTuner: params?.disableTuner,
moderationOpts, moderationOpts,
ignoreFilterFor: opts?.ignoreFilterFor, ignoreFilterFor: opts?.ignoreFilterFor,
isDiscover, isDiscover,
}), }),
[ [feedTuners, moderationOpts, opts?.ignoreFilterFor, isDiscover],
feedTuners,
params?.disableTuner,
moderationOpts,
opts?.ignoreFilterFor,
isDiscover,
],
) )
const query = useInfiniteQuery< const query = useInfiniteQuery<
@ -232,17 +224,10 @@ export function usePostFeedQuery(
(data: InfiniteData<FeedPageUnselected, RQPageParam>) => { (data: InfiniteData<FeedPageUnselected, RQPageParam>) => {
// If the selection depends on some data, that data should // If the selection depends on some data, that data should
// be included in the selectArgs object and read here. // be included in the selectArgs object and read here.
const { const {feedTuners, moderationOpts, ignoreFilterFor, isDiscover} =
feedTuners, selectArgs
disableTuner,
moderationOpts,
ignoreFilterFor,
isDiscover,
} = selectArgs
const tuner = disableTuner const tuner = new FeedTuner(feedTuners)
? new NoopFeedTuner()
: new FeedTuner(feedTuners)
// Keep track of the last run and whether we can reuse // Keep track of the last run and whether we can reuse
// some already selected pages from there. // some already selected pages from there.