From c2bfa111ac1f2c5fed2dd1caa92106849b14eaec Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Fri, 3 Mar 2023 14:43:18 -0600 Subject: [PATCH] Remove replies from the home feed (#259) * Remove replies from the home feed (close #252) * Increase the 'load more' threshhold --- src/state/models/feed-view.ts | 45 +++++++++++++++++++++++------------ src/view/com/posts/Feed.tsx | 5 ++-- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts index 645b1f2e..ed5a32d8 100644 --- a/src/state/models/feed-view.ts +++ b/src/state/models/feed-view.ts @@ -239,22 +239,33 @@ export class FeedModel { } get nonReplyFeed() { - const nonReplyFeed = this.feed.filter(item => { - const params = this.params as GetAuthorFeed.QueryParams - const isRepost = - item.reply && - (item?.reasonRepost?.by?.handle === params.author || - item?.reasonRepost?.by?.did === params.author) + if (this.feedType === 'author') { + return this.feed.filter(item => { + const params = this.params as GetAuthorFeed.QueryParams + const isRepost = + item.reply && + (item?.reasonRepost?.by?.handle === params.author || + item?.reasonRepost?.by?.did === params.author) - return ( - !item.reply || // not a reply - isRepost || - ((item._isThreadParent || // but allow if it's a thread by the user - item._isThreadChild) && - item.reply?.root.author.did === item.post.author.did) - ) - }) - return nonReplyFeed + return ( + !item.reply || // not a reply + isRepost || + ((item._isThreadParent || // but allow if it's a thread by the user + item._isThreadChild) && + item.reply?.root.author.did === item.post.author.did) + ) + }) + } else { + return this.feed.filter(item => { + const isRepost = Boolean(item?.reasonRepost) + return ( + !item.reply || // not a reply + isRepost || // but allow if it's a repost or thread + item._isThreadParent || + item._isThreadChild + ) + }) + } } setHasNewLatest(v: boolean) { @@ -423,6 +434,10 @@ export class FeedModel { if (!item) { return } + if (item.reply) { + // TEMPORARY ignore replies + return + } if (AppBskyFeedFeedViewPost.isReasonRepost(item.reason)) { if (item.reason.by.did === this.rootStore.me.did) { return // ignore reposts by the user diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index 03a719f1..a4963e0d 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -61,7 +61,7 @@ export const Feed = observer(function Feed({ if (feed.isEmpty) { feedItems = feedItems.concat([EMPTY_FEED_ITEM]) } else { - feedItems = feedItems.concat(feed.feed) + feedItems = feedItems.concat(feed.nonReplyFeed) } } return feedItems @@ -69,7 +69,7 @@ export const Feed = observer(function Feed({ feed.hasError, feed.hasLoaded, feed.isEmpty, - feed.feed, + feed.nonReplyFeed, showWelcomeBanner, isNewUser, ]) @@ -171,6 +171,7 @@ export const Feed = observer(function Feed({ onScroll={onScroll} onRefresh={onRefresh} onEndReached={onEndReached} + onEndReachedThreshold={0.25} removeClippedSubviews={true} contentInset={{top: headerOffset}} contentOffset={{x: 0, y: headerOffset * -1}}