From 8c675248d45c01db255a63cd98dc58868ec329fa Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 2 May 2023 21:51:25 -0500 Subject: [PATCH] Fix replies with <2 likes showing in the following feed --- src/lib/api/feed-manip.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/api/feed-manip.ts b/src/lib/api/feed-manip.ts index 341e8727..60e75504 100644 --- a/src/lib/api/feed-manip.ts +++ b/src/lib/api/feed-manip.ts @@ -1,4 +1,4 @@ -import {AppBskyFeedDefs} from '@atproto/api' +import {AppBskyFeedDefs, AppBskyFeedPost} from '@atproto/api' import lande from 'lande' import {hasProp} from 'lib/type-guards' import {LANGUAGES_MAP_CODE2} from '../../locale/languages' @@ -48,6 +48,13 @@ export class FeedViewPostsSlice { return this.items[0] } + get isReply() { + return ( + AppBskyFeedPost.isRecord(this.rootItem.post.record) && + !!this.rootItem.post.record.reply + ) + } + containsUri(uri: string) { return !!this.items.find(item => item.post.uri === uri) } @@ -176,9 +183,10 @@ export class FeedTuner { ): FeedViewPostsSlice[] { // remove any replies without at least 2 likes 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 } + const item = slices[i].rootItem const isRepost = Boolean(item.reason) if (!isRepost && (item.post.likeCount || 0) < 2) {