Merge branch 'main' into ansh/app-812-add-custom-feed-discovery-to-onboarding

zio/stable
Ansh Nanda 2023-08-28 17:49:14 -07:00
commit b38629b9b5
4 changed files with 11 additions and 34 deletions

View File

@ -122,7 +122,7 @@ export const FeedItem = observer(function ({
}
if (item.isReply || item.isMention || item.isQuote) {
if (item.additionalPost?.error) {
if (!item.additionalPost || item.additionalPost?.error) {
// hide errors - it doesnt help the user to show them
return <View />
}
@ -134,8 +134,7 @@ export const FeedItem = observer(function ({
noFeedback
accessible={false}>
<Post
uri={item.uri}
initView={item.additionalPost}
view={item.additionalPost}
style={
item.isRead
? undefined

View File

@ -1,4 +1,5 @@
import React, {useRef} from 'react'
import {runInAction} from 'mobx'
import {observer} from 'mobx-react-lite'
import {
ActivityIndicator,
@ -361,7 +362,9 @@ function* flattenThread(
}
}
} else if (!isAscending && !post.parent && post.post.replyCount) {
runInAction(() => {
post._hasMore = true
})
}
}

View File

@ -1,4 +1,4 @@
import React, {useEffect, useState, useMemo} from 'react'
import React, {useState, useMemo} from 'react'
import {
ActivityIndicator,
Linking,
@ -32,35 +32,19 @@ import {getTranslatorLink, isPostInLanguage} from '../../../locale/helpers'
import {makeProfileLink} from 'lib/routes/links'
export const Post = observer(function Post({
uri,
initView,
view,
showReplyLine,
hideError,
style,
}: {
uri: string
initView?: PostThreadModel
view: PostThreadModel
showReplyLine?: boolean
hideError?: boolean
style?: StyleProp<ViewStyle>
}) {
const pal = usePalette('default')
const store = useStores()
const [view, setView] = useState<PostThreadModel | undefined>(initView)
const [deleted, setDeleted] = useState(false)
useEffect(() => {
if (initView || view?.params.uri === uri) {
if (initView !== view) {
setView(initView)
}
return
}
const newView = new PostThreadModel(store, {uri, depth: 0})
setView(newView)
newView.setup().catch(err => store.log.error('Failed to fetch post', err))
}, [initView, setView, uri, view, view?.params.uri, store])
// deleted
// =
if (deleted) {
@ -69,11 +53,7 @@ export const Post = observer(function Post({
// loading
// =
if (
!view ||
(!view.hasContent && view.isLoading) ||
view.params.uri !== uri
) {
if (!view.hasContent && view.isLoading) {
return (
<View style={pal.view}>
<ActivityIndicator />

View File

@ -72,12 +72,7 @@ const PostResults = observer(({model}: {model: SearchUIModel}) => {
return (
<ScrollView style={[pal.view]}>
{model.posts.map(post => (
<Post
key={post.resolvedUri}
uri={post.resolvedUri}
initView={post}
hideError
/>
<Post key={post.resolvedUri} view={post} hideError />
))}
<View style={s.footerSpacer} />
<View style={s.footerSpacer} />