Merge branch 'main' of github.com:bluesky-social/social-app into main

zio/stable
Paul Frazee 2023-08-22 10:50:45 -07:00
commit fb1199e21d
4 changed files with 44 additions and 13 deletions

View File

@ -11,9 +11,18 @@ import {cleanError} from 'lib/strings/errors'
import {FeedTuner} from 'lib/api/feed-manip' import {FeedTuner} from 'lib/api/feed-manip'
import {PostsFeedSliceModel} from './posts-slice' import {PostsFeedSliceModel} from './posts-slice'
import {track} from 'lib/analytics/analytics' import {track} from 'lib/analytics/analytics'
import {FeedViewPostsSlice} from 'lib/api/feed-manip'
const PAGE_SIZE = 30 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 = type QueryParams =
| GetTimeline.QueryParams | GetTimeline.QueryParams
| GetAuthorFeed.QueryParams | GetAuthorFeed.QueryParams
@ -35,6 +44,7 @@ export class PostsFeedModel {
pollCursor: string | undefined pollCursor: string | undefined
tuner = new FeedTuner() tuner = new FeedTuner()
pageSize = PAGE_SIZE pageSize = PAGE_SIZE
options: Options = {}
// used to linearize async modifications to state // used to linearize async modifications to state
lock = new AwaitLock() lock = new AwaitLock()
@ -49,6 +59,7 @@ export class PostsFeedModel {
public rootStore: RootStoreModel, public rootStore: RootStoreModel,
public feedType: 'home' | 'author' | 'custom', public feedType: 'home' | 'author' | 'custom',
params: QueryParams, params: QueryParams,
options?: Options,
) { ) {
makeAutoObservable( makeAutoObservable(
this, this,
@ -60,6 +71,7 @@ export class PostsFeedModel {
{autoBind: true}, {autoBind: true},
) )
this.params = params this.params = params
this.options = options || {}
} }
get hasContent() { get hasContent() {
@ -354,7 +366,9 @@ export class PostsFeedModel {
this.rootStore.posts.fromFeedItem(item) 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[] = [] const toAppend: PostsFeedSliceModel[] = []
for (const slice of slices) { for (const slice of slices) {

View File

@ -176,11 +176,18 @@ export class ProfileUiModel {
filter = 'posts_with_media' filter = 'posts_with_media'
} }
this.feed = new PostsFeedModel(this.rootStore, 'author', { this.feed = new PostsFeedModel(
this.rootStore,
'author',
{
actor: this.params.user, actor: this.params.user,
limit: 10, limit: 10,
filter, filter,
}) },
{
isSimpleFeed: ['posts_with_media'].includes(filter),
},
)
if (this.currentView instanceof PostsFeedModel) { if (this.currentView instanceof PostsFeedModel) {
this.feed.setup() this.feed.setup()

View File

@ -156,7 +156,7 @@ export const PostThread = observer(function PostThread({
}, [navigation]) }, [navigation])
const renderItem = React.useCallback( const renderItem = React.useCallback(
({item}: {item: YieldedItem}) => { ({item, index}: {item: YieldedItem; index: number}) => {
if (item === PARENT_SPINNER) { if (item === PARENT_SPINNER) {
return ( return (
<View style={styles.parentSpinner}> <View style={styles.parentSpinner}>
@ -205,11 +205,20 @@ export const PostThread = observer(function PostThread({
</View> </View>
) )
} else if (item instanceof PostThreadItemModel) { } else if (item instanceof PostThreadItemModel) {
return <PostThreadItem item={item} onPostReply={onRefresh} /> const prev = (
index - 1 >= 0 ? posts[index - 1] : undefined
) as PostThreadItemModel
return (
<PostThreadItem
item={item}
onPostReply={onRefresh}
hasPrecedingItem={prev?._showChildReplyLine}
/>
)
} }
return <></> return <></>
}, },
[onRefresh, onPressReply, pal], [onRefresh, onPressReply, pal, posts],
) )
// loading // loading

View File

@ -38,9 +38,11 @@ import {isDesktopWeb} from 'platform/detection'
export const PostThreadItem = observer(function PostThreadItem({ export const PostThreadItem = observer(function PostThreadItem({
item, item,
onPostReply, onPostReply,
hasPrecedingItem,
}: { }: {
item: PostThreadItemModel item: PostThreadItemModel
onPostReply: () => void onPostReply: () => void
hasPrecedingItem: boolean
}) { }) {
const pal = usePalette('default') const pal = usePalette('default')
const store = useStores() const store = useStores()
@ -359,8 +361,7 @@ export const PostThreadItem = observer(function PostThreadItem({
styles.outer, styles.outer,
pal.border, pal.border,
pal.view, pal.view,
item._showParentReplyLine && styles.noTopBorder, item._showParentReplyLine && hasPrecedingItem && styles.noTopBorder,
!item._showChildReplyLine && {borderBottomWidth: 1},
]} ]}
moderation={item.moderation.content}> moderation={item.moderation.content}>
<PostSandboxWarning /> <PostSandboxWarning />
@ -483,7 +484,7 @@ export const PostThreadItem = observer(function PostThreadItem({
<Link <Link
style={[ style={[
styles.loadMore, styles.loadMore,
{borderBottomColor: pal.colors.border}, {borderTopColor: pal.colors.border},
pal.view, pal.view,
]} ]}
href={itemHref} href={itemHref}
@ -600,7 +601,7 @@ const styles = StyleSheet.create({
loadMore: { loadMore: {
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'space-between', justifyContent: 'space-between',
borderBottomWidth: 1, borderTopWidth: 1,
paddingLeft: 80, paddingLeft: 80,
paddingRight: 20, paddingRight: 20,
paddingVertical: 12, paddingVertical: 12,