Feed fixes: repeat posts & nonreplies showing up in the wrong place (#516)
* Fix the repeat posts issue on the home feed * Fix: replies no longer show up in the no-replies feedzio/stable
parent
d35f7c1f1a
commit
5085861b9a
|
@ -294,12 +294,10 @@ export class PostsFeedModel {
|
||||||
const isRepost =
|
const isRepost =
|
||||||
item?.reasonRepost?.by?.handle === params.actor ||
|
item?.reasonRepost?.by?.handle === params.actor ||
|
||||||
item?.reasonRepost?.by?.did === params.actor
|
item?.reasonRepost?.by?.did === params.actor
|
||||||
return (
|
const allow =
|
||||||
!item.reply || // not a reply
|
!item.postRecord?.reply || // not a reply
|
||||||
isRepost || // but allow if it's a repost
|
isRepost // but allow if it's a repost
|
||||||
(slice.isThread && // or a thread by the user
|
return allow
|
||||||
item.reply?.root.author.did === item.post.author.did)
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return this.slices
|
return this.slices
|
||||||
|
|
|
@ -6,6 +6,7 @@ import useAppState from 'react-native-appstate-hook'
|
||||||
import {NativeStackScreenProps, HomeTabNavigatorParams} from 'lib/routes/types'
|
import {NativeStackScreenProps, HomeTabNavigatorParams} from 'lib/routes/types'
|
||||||
import {PostsFeedModel} from 'state/models/feeds/posts'
|
import {PostsFeedModel} from 'state/models/feeds/posts'
|
||||||
import {withAuthRequired} from 'view/com/auth/withAuthRequired'
|
import {withAuthRequired} from 'view/com/auth/withAuthRequired'
|
||||||
|
import {useTabFocusEffect} from 'lib/hooks/useTabFocusEffect'
|
||||||
import {Feed} from '../com/posts/Feed'
|
import {Feed} from '../com/posts/Feed'
|
||||||
import {FollowingEmptyState} from 'view/com/posts/FollowingEmptyState'
|
import {FollowingEmptyState} from 'view/com/posts/FollowingEmptyState'
|
||||||
import {LoadLatestBtn} from '../com/util/load-latest/LoadLatestBtn'
|
import {LoadLatestBtn} from '../com/util/load-latest/LoadLatestBtn'
|
||||||
|
@ -143,9 +144,10 @@ const FeedPage = observer(
|
||||||
|
|
||||||
const onSoftReset = React.useCallback(() => {
|
const onSoftReset = React.useCallback(() => {
|
||||||
if (isPageFocused) {
|
if (isPageFocused) {
|
||||||
|
feed.refresh()
|
||||||
scrollToTop()
|
scrollToTop()
|
||||||
}
|
}
|
||||||
}, [isPageFocused, scrollToTop])
|
}, [isPageFocused, scrollToTop, feed])
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
React.useCallback(() => {
|
React.useCallback(() => {
|
||||||
|
@ -166,6 +168,30 @@ const FeedPage = observer(
|
||||||
}
|
}
|
||||||
}, [store, doPoll, onSoftReset, screen, feed]),
|
}, [store, doPoll, onSoftReset, screen, feed]),
|
||||||
)
|
)
|
||||||
|
useTabFocusEffect(
|
||||||
|
'Home',
|
||||||
|
React.useCallback(
|
||||||
|
isInside => {
|
||||||
|
if (!isPageFocused) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// on mobile:
|
||||||
|
// fires with `isInside=true` when the user navigates to the root tab
|
||||||
|
// but not when the user goes back to the screen by pressing back
|
||||||
|
// on web:
|
||||||
|
// essentially equivalent to useFocusEffect because we dont used tabbed
|
||||||
|
// navigation
|
||||||
|
if (isInside) {
|
||||||
|
if (feed.hasNewLatest) {
|
||||||
|
feed.refresh()
|
||||||
|
} else {
|
||||||
|
feed.checkForLatest()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[isPageFocused, feed],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
const onPressCompose = React.useCallback(() => {
|
const onPressCompose = React.useCallback(() => {
|
||||||
track('HomeScreen:PressCompose')
|
track('HomeScreen:PressCompose')
|
||||||
|
|
Loading…
Reference in New Issue