diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-09-20 19:47:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-20 19:47:56 -0700 |
commit | 5a945c2024855b89dfb99f81a2c4d226bb39dc32 (patch) | |
tree | 3a42e8e8d79c281606c2b7d9bff9380df596d8c7 /src/state/models/ui/preferences.ts | |
parent | 68dd3210d11bf8a15c319768d3e338c629a69d4b (diff) | |
download | voidsky-5a945c2024855b89dfb99f81a2c4d226bb39dc32.tar.zst |
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
Diffstat (limited to 'src/state/models/ui/preferences.ts')
-rw-r--r-- | src/state/models/ui/preferences.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/state/models/ui/preferences.ts b/src/state/models/ui/preferences.ts index 5c6ea230b..5e07685ca 100644 --- a/src/state/models/ui/preferences.ts +++ b/src/state/models/ui/preferences.ts @@ -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 |