diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts index 6facc27ad0..93add8102c 100644 --- a/src/state/models/feeds/posts.ts +++ b/src/state/models/feeds/posts.ts @@ -11,9 +11,18 @@ import {cleanError} from 'lib/strings/errors' import {FeedTuner} from 'lib/api/feed-manip' import {PostsFeedSliceModel} from './posts-slice' import {track} from 'lib/analytics/analytics' +import {FeedViewPostsSlice} from 'lib/api/feed-manip' const PAGE_SIZE = 30 +type Options = { + /** + * Formats the feed in a flat array with no threading of replies, just + * top-level posts. + */ + isSimpleFeed?: boolean +} + type QueryParams = | GetTimeline.QueryParams | GetAuthorFeed.QueryParams @@ -35,6 +44,7 @@ export class PostsFeedModel { pollCursor: string | undefined tuner = new FeedTuner() pageSize = PAGE_SIZE + options: Options = {} // used to linearize async modifications to state lock = new AwaitLock() @@ -49,6 +59,7 @@ export class PostsFeedModel { public rootStore: RootStoreModel, public feedType: 'home' | 'author' | 'custom', params: QueryParams, + options?: Options, ) { makeAutoObservable( this, @@ -60,6 +71,7 @@ export class PostsFeedModel { {autoBind: true}, ) this.params = params + this.options = options || {} } get hasContent() { @@ -354,7 +366,9 @@ export class PostsFeedModel { this.rootStore.posts.fromFeedItem(item) } - const slices = this.tuner.tune(res.data.feed, this.feedTuners) + const slices = this.options.isSimpleFeed + ? res.data.feed.map(item => new FeedViewPostsSlice([item])) + : this.tuner.tune(res.data.feed, this.feedTuners) const toAppend: PostsFeedSliceModel[] = [] for (const slice of slices) { diff --git a/src/state/models/ui/profile.ts b/src/state/models/ui/profile.ts index 9dae09ec5c..e026a27fc1 100644 --- a/src/state/models/ui/profile.ts +++ b/src/state/models/ui/profile.ts @@ -176,11 +176,18 @@ export class ProfileUiModel { filter = 'posts_with_media' } - this.feed = new PostsFeedModel(this.rootStore, 'author', { - actor: this.params.user, - limit: 10, - filter, - }) + this.feed = new PostsFeedModel( + this.rootStore, + 'author', + { + actor: this.params.user, + limit: 10, + filter, + }, + { + isSimpleFeed: ['posts_with_media'].includes(filter), + }, + ) if (this.currentView instanceof PostsFeedModel) { this.feed.setup() diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index 399e47006c..e3dd2cf1d1 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -156,7 +156,7 @@ export const PostThread = observer(function PostThread({ }, [navigation]) const renderItem = React.useCallback( - ({item}: {item: YieldedItem}) => { + ({item, index}: {item: YieldedItem; index: number}) => { if (item === PARENT_SPINNER) { return ( @@ -205,11 +205,20 @@ export const PostThread = observer(function PostThread({ ) } else if (item instanceof PostThreadItemModel) { - return + const prev = ( + index - 1 >= 0 ? posts[index - 1] : undefined + ) as PostThreadItemModel + return ( + + ) } return <> }, - [onRefresh, onPressReply, pal], + [onRefresh, onPressReply, pal, posts], ) // loading diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 8a56012f0f..e44151ac50 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -38,9 +38,11 @@ import {isDesktopWeb} from 'platform/detection' export const PostThreadItem = observer(function PostThreadItem({ item, onPostReply, + hasPrecedingItem, }: { item: PostThreadItemModel onPostReply: () => void + hasPrecedingItem: boolean }) { const pal = usePalette('default') const store = useStores() @@ -359,8 +361,7 @@ export const PostThreadItem = observer(function PostThreadItem({ styles.outer, pal.border, pal.view, - item._showParentReplyLine && styles.noTopBorder, - !item._showChildReplyLine && {borderBottomWidth: 1}, + item._showParentReplyLine && hasPrecedingItem && styles.noTopBorder, ]} moderation={item.moderation.content}> @@ -483,7 +484,7 @@ export const PostThreadItem = observer(function PostThreadItem({