Prefilter the mergefeed to ensure a better mix of following and custom feeds (#1498)
* Prefilter the mergefeed to ensure a better mix of following and custom feeds * Test suite improvements & tests for the mergefeed (#1499) * Disable invite codes test for now * Update test sim to latest iphone * Introduce TestCtrls driver * Add mergefeed tests
This commit is contained in:
parent
68dd3210d1
commit
5a945c2024
30 changed files with 518 additions and 164 deletions
|
@ -139,53 +139,6 @@ export class PostsFeedModel {
|
|||
this.tuner.reset()
|
||||
}
|
||||
|
||||
get feedTuners() {
|
||||
const areRepliesEnabled = this.rootStore.preferences.homeFeedRepliesEnabled
|
||||
const areRepliesByFollowedOnlyEnabled =
|
||||
this.rootStore.preferences.homeFeedRepliesByFollowedOnlyEnabled
|
||||
const repliesThreshold = this.rootStore.preferences.homeFeedRepliesThreshold
|
||||
const areRepostsEnabled = this.rootStore.preferences.homeFeedRepostsEnabled
|
||||
const areQuotePostsEnabled =
|
||||
this.rootStore.preferences.homeFeedQuotePostsEnabled
|
||||
|
||||
if (this.feedType === 'custom') {
|
||||
return [
|
||||
FeedTuner.dedupReposts,
|
||||
FeedTuner.preferredLangOnly(
|
||||
this.rootStore.preferences.contentLanguages,
|
||||
),
|
||||
]
|
||||
}
|
||||
if (this.feedType === 'home' || this.feedType === 'following') {
|
||||
const feedTuners = []
|
||||
|
||||
if (areRepostsEnabled) {
|
||||
feedTuners.push(FeedTuner.dedupReposts)
|
||||
} else {
|
||||
feedTuners.push(FeedTuner.removeReposts)
|
||||
}
|
||||
|
||||
if (areRepliesEnabled) {
|
||||
feedTuners.push(
|
||||
FeedTuner.thresholdRepliesOnly({
|
||||
userDid: this.rootStore.session.data?.did || '',
|
||||
minLikes: repliesThreshold,
|
||||
followedOnly: areRepliesByFollowedOnlyEnabled,
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
feedTuners.push(FeedTuner.removeReplies)
|
||||
}
|
||||
|
||||
if (!areQuotePostsEnabled) {
|
||||
feedTuners.push(FeedTuner.removeQuotePosts)
|
||||
}
|
||||
|
||||
return feedTuners
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* Load for first render
|
||||
*/
|
||||
|
@ -275,9 +228,14 @@ export class PostsFeedModel {
|
|||
}
|
||||
const post = await this.api.peekLatest()
|
||||
if (post) {
|
||||
const slices = this.tuner.tune([post], this.feedTuners, {
|
||||
dryRun: true,
|
||||
})
|
||||
const slices = this.tuner.tune(
|
||||
[post],
|
||||
this.rootStore.preferences.getFeedTuners(this.feedType),
|
||||
{
|
||||
dryRun: true,
|
||||
maintainOrder: true,
|
||||
},
|
||||
)
|
||||
if (slices[0]) {
|
||||
const sliceModel = new PostsFeedSliceModel(this.rootStore, slices[0])
|
||||
if (sliceModel.moderation.content.filter) {
|
||||
|
@ -363,7 +321,10 @@ export class PostsFeedModel {
|
|||
|
||||
const slices = this.options.isSimpleFeed
|
||||
? res.feed.map(item => new FeedViewPostsSlice([item]))
|
||||
: this.tuner.tune(res.feed, this.feedTuners)
|
||||
: this.tuner.tune(
|
||||
res.feed,
|
||||
this.rootStore.preferences.getFeedTuners(this.feedType),
|
||||
)
|
||||
|
||||
const toAppend: PostsFeedSliceModel[] = []
|
||||
for (const slice of slices) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import {ModerationOpts} from '@atproto/api'
|
|||
import {DEFAULT_FEEDS} from 'lib/constants'
|
||||
import {deviceLocales} from 'platform/detection'
|
||||
import {getAge} from 'lib/strings/time'
|
||||
import {FeedTuner} from 'lib/api/feed-manip'
|
||||
import {LANGUAGES} from '../../../locale/languages'
|
||||
|
||||
// TEMP we need to permanently convert 'show' to 'ignore', for now we manually convert -prf
|
||||
|
@ -540,6 +541,52 @@ export class PreferencesModel {
|
|||
toggleRequireAltTextEnabled() {
|
||||
this.requireAltTextEnabled = !this.requireAltTextEnabled
|
||||
}
|
||||
|
||||
getFeedTuners(
|
||||
feedType: 'home' | 'following' | 'author' | 'custom' | 'likes',
|
||||
) {
|
||||
const areRepliesEnabled = this.homeFeedRepliesEnabled
|
||||
const areRepliesByFollowedOnlyEnabled =
|
||||
this.homeFeedRepliesByFollowedOnlyEnabled
|
||||
const repliesThreshold = this.homeFeedRepliesThreshold
|
||||
const areRepostsEnabled = this.homeFeedRepostsEnabled
|
||||
const areQuotePostsEnabled = this.homeFeedQuotePostsEnabled
|
||||
|
||||
if (feedType === 'custom') {
|
||||
return [
|
||||
FeedTuner.dedupReposts,
|
||||
FeedTuner.preferredLangOnly(this.contentLanguages),
|
||||
]
|
||||
}
|
||||
if (feedType === 'home' || feedType === 'following') {
|
||||
const feedTuners = []
|
||||
|
||||
if (areRepostsEnabled) {
|
||||
feedTuners.push(FeedTuner.dedupReposts)
|
||||
} else {
|
||||
feedTuners.push(FeedTuner.removeReposts)
|
||||
}
|
||||
|
||||
if (areRepliesEnabled) {
|
||||
feedTuners.push(
|
||||
FeedTuner.thresholdRepliesOnly({
|
||||
userDid: this.rootStore.session.data?.did || '',
|
||||
minLikes: repliesThreshold,
|
||||
followedOnly: areRepliesByFollowedOnlyEnabled,
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
feedTuners.push(FeedTuner.removeReplies)
|
||||
}
|
||||
|
||||
if (!areQuotePostsEnabled) {
|
||||
feedTuners.push(FeedTuner.removeQuotePosts)
|
||||
}
|
||||
|
||||
return feedTuners
|
||||
}
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
// TEMP we need to permanently convert 'show' to 'ignore', for now we manually convert -prf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue