Fix replies with <2 likes showing in the following feed

zio/stable
Paul Frazee 2023-05-02 21:51:25 -05:00
parent d225e857b5
commit 8c675248d4
1 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import {AppBskyFeedDefs} from '@atproto/api' import {AppBskyFeedDefs, AppBskyFeedPost} from '@atproto/api'
import lande from 'lande' import lande from 'lande'
import {hasProp} from 'lib/type-guards' import {hasProp} from 'lib/type-guards'
import {LANGUAGES_MAP_CODE2} from '../../locale/languages' import {LANGUAGES_MAP_CODE2} from '../../locale/languages'
@ -48,6 +48,13 @@ export class FeedViewPostsSlice {
return this.items[0] return this.items[0]
} }
get isReply() {
return (
AppBskyFeedPost.isRecord(this.rootItem.post.record) &&
!!this.rootItem.post.record.reply
)
}
containsUri(uri: string) { containsUri(uri: string) {
return !!this.items.find(item => item.post.uri === uri) return !!this.items.find(item => item.post.uri === uri)
} }
@ -176,9 +183,10 @@ export class FeedTuner {
): FeedViewPostsSlice[] { ): FeedViewPostsSlice[] {
// remove any replies without at least 2 likes // remove any replies without at least 2 likes
for (let i = slices.length - 1; i >= 0; i--) { for (let i = slices.length - 1; i >= 0; i--) {
if (slices[i].isFullThread || !slices[i].rootItem.reply) { if (slices[i].isFullThread || !slices[i].isReply) {
continue continue
} }
const item = slices[i].rootItem const item = slices[i].rootItem
const isRepost = Boolean(item.reason) const isRepost = Boolean(item.reason)
if (!isRepost && (item.post.likeCount || 0) < 2) { if (!isRepost && (item.post.likeCount || 0) < 2) {