diff options
Diffstat (limited to 'src/view/com/posts/Feed.tsx')
-rw-r--r-- | src/view/com/posts/Feed.tsx | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index 02a3537eb..04753fe6c 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -28,13 +28,18 @@ import {isWeb} from '#/platform/detection' import {listenPostCreated} from '#/state/events' import {useSession} from '#/state/session' import {STALE} from '#/state/queries' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' +import {DiscoverFallbackHeader} from './DiscoverFallbackHeader' +import {FALLBACK_MARKER_POST} from '#/lib/api/feed/home' const LOADING_ITEM = {_reactKey: '__loading__'} const EMPTY_FEED_ITEM = {_reactKey: '__empty__'} const ERROR_ITEM = {_reactKey: '__error__'} const LOAD_MORE_ERROR_ITEM = {_reactKey: '__load_more_error__'} -const REFRESH_AFTER = STALE.HOURS.ONE +// DISABLED need to check if this is causing random feed refreshes -prf +// const REFRESH_AFTER = STALE.HOURS.ONE const CHECK_LATEST_AFTER = STALE.SECONDS.THIRTY let Feed = ({ @@ -44,6 +49,7 @@ let Feed = ({ style, enabled, pollInterval, + disablePoll, scrollElRef, onScrolledDownChange, onHasNew, @@ -61,6 +67,7 @@ let Feed = ({ style?: StyleProp<ViewStyle> enabled?: boolean pollInterval?: number + disablePoll?: boolean scrollElRef?: ListRef onHasNew?: (v: boolean) => void onScrolledDownChange?: (isScrolledDown: boolean) => void @@ -74,6 +81,7 @@ let Feed = ({ }): React.ReactNode => { const theme = useTheme() const {track} = useAnalytics() + const {_} = useLingui() const queryClient = useQueryClient() const {currentAccount} = useSession() const [isPTRing, setIsPTRing] = React.useState(false) @@ -104,7 +112,7 @@ let Feed = ({ ) const checkForNew = React.useCallback(async () => { - if (!data?.pages[0] || isFetching || !onHasNew || !enabled) { + if (!data?.pages[0] || isFetching || !onHasNew || !enabled || disablePoll) { return } try { @@ -114,7 +122,7 @@ let Feed = ({ } catch (e) { logger.error('Poll latest failed', {feed, error: String(e)}) } - }, [feed, data, isFetching, onHasNew, enabled]) + }, [feed, data, isFetching, onHasNew, enabled, disablePoll]) const myDid = currentAccount?.did || '' const onPostCreated = React.useCallback(() => { @@ -143,11 +151,12 @@ let Feed = ({ React.useEffect(() => { if (enabled) { const timeSinceFirstLoad = Date.now() - lastFetchRef.current - if (timeSinceFirstLoad > REFRESH_AFTER) { + // DISABLED need to check if this is causing random feed refreshes -prf + /*if (timeSinceFirstLoad > REFRESH_AFTER) { // do a full refresh scrollElRef?.current?.scrollToOffset({offset: 0, animated: false}) queryClient.resetQueries({queryKey: RQKEY(feed)}) - } else if ( + } else*/ if ( timeSinceFirstLoad > CHECK_LATEST_AFTER && checkForNewRef.current ) { @@ -250,16 +259,24 @@ let Feed = ({ } else if (item === LOAD_MORE_ERROR_ITEM) { return ( <LoadMoreRetryBtn - label="There was an issue fetching posts. Tap here to try again." + label={_( + msg`There was an issue fetching posts. Tap here to try again.`, + )} onPress={onPressRetryLoadMore} /> ) } else if (item === LOADING_ITEM) { return <PostFeedLoadingPlaceholder /> + } else if (item.rootUri === FALLBACK_MARKER_POST.post.uri) { + // HACK + // tell the user we fell back to discover + // see home.ts (feed api) for more info + // -prf + return <DiscoverFallbackHeader /> } return <FeedSlice slice={item} /> }, - [feed, error, onPressTryAgain, onPressRetryLoadMore, renderEmptyState], + [feed, error, onPressTryAgain, onPressRetryLoadMore, renderEmptyState, _], ) const shouldRenderEndOfFeed = |