Dont apply the content-language filter if it will remove all content (#3492)
* Dont apply the content-language filter if it will remove all content * Improve codezio/stable
parent
ad97d4350c
commit
ed2c8b720e
|
@ -1,11 +1,12 @@
|
||||||
import {
|
import {
|
||||||
|
AppBskyEmbedRecord,
|
||||||
|
AppBskyEmbedRecordWithMedia,
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
AppBskyFeedPost,
|
AppBskyFeedPost,
|
||||||
AppBskyEmbedRecordWithMedia,
|
|
||||||
AppBskyEmbedRecord,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {ReasonFeedSource} from './feed/types'
|
|
||||||
import {isPostInLanguage} from '../../locale/helpers'
|
import {isPostInLanguage} from '../../locale/helpers'
|
||||||
|
import {ReasonFeedSource} from './feed/types'
|
||||||
type FeedViewPost = AppBskyFeedDefs.FeedViewPost
|
type FeedViewPost = AppBskyFeedDefs.FeedViewPost
|
||||||
|
|
||||||
export type FeedTunerFn = (
|
export type FeedTunerFn = (
|
||||||
|
@ -341,6 +342,8 @@ export class FeedTuner {
|
||||||
tuner: FeedTuner,
|
tuner: FeedTuner,
|
||||||
slices: FeedViewPostsSlice[],
|
slices: FeedViewPostsSlice[],
|
||||||
): FeedViewPostsSlice[] => {
|
): FeedViewPostsSlice[] => {
|
||||||
|
const candidateSlices = slices.slice()
|
||||||
|
|
||||||
// early return if no languages have been specified
|
// early return if no languages have been specified
|
||||||
if (!preferredLangsCode2.length || preferredLangsCode2.length === 0) {
|
if (!preferredLangsCode2.length || preferredLangsCode2.length === 0) {
|
||||||
return slices
|
return slices
|
||||||
|
@ -357,10 +360,17 @@ export class FeedTuner {
|
||||||
|
|
||||||
// if item does not fit preferred language, remove it
|
// if item does not fit preferred language, remove it
|
||||||
if (!hasPreferredLang) {
|
if (!hasPreferredLang) {
|
||||||
slices.splice(i, 1)
|
candidateSlices.splice(i, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return slices
|
|
||||||
|
// if the language filter cleared out the entire page, return the original set
|
||||||
|
// so that something always shows
|
||||||
|
if (candidateSlices.length === 0) {
|
||||||
|
return slices
|
||||||
|
}
|
||||||
|
|
||||||
|
return candidateSlices
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue