More custom-feed behavior fixes [APP-678] (#831)

* Remove extraneous custom-feed health check

* Fixes to custom feed preference sync

* Fix lint

* Remove dead code (client-side suggested posts constructor)

* Enforce the feed-fetch limit in the client if the generator fails to observe the parameter

* Bump the number of items fetched in the multifeed per feed from 5 to 10

* Reset the currently active feed when the pinned feeds change

* Some fixes to icons

* Add a prompt to load latest to the multifeed

* Remove debug
This commit is contained in:
Paul Frazee 2023-06-02 09:48:53 -05:00 committed by GitHub
parent e9c84a192b
commit 3217c7ff32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 88 additions and 186 deletions

View file

@ -14,11 +14,13 @@ import {PostsMultiFeedModel} from 'state/models/feeds/multi-feed'
import {MultiFeed} from 'view/com/posts/MultiFeed'
import {isDesktopWeb} from 'platform/detection'
import {usePalette} from 'lib/hooks/usePalette'
import {useTimer} from 'lib/hooks/useTimer'
import {useStores} from 'state/index'
import {useOnMainScroll} from 'lib/hooks/useOnMainScroll'
import {ComposeIcon2, CogIcon} from 'lib/icons'
import {s} from 'lib/styles'
const LOAD_NEW_PROMPT_TIME = 60e3 // 60 seconds
const HEADER_OFFSET = isDesktopWeb ? 0 : 40
type Props = NativeStackScreenProps<FeedsTabNavigatorParams, 'Feeds'>
@ -33,11 +35,24 @@ export const FeedsScreen = withAuthRequired(
)
const [onMainScroll, isScrolledDown, resetMainScroll] =
useOnMainScroll(store)
const [loadPromptVisible, setLoadPromptVisible] = React.useState(false)
const [resetPromptTimer] = useTimer(LOAD_NEW_PROMPT_TIME, () => {
setLoadPromptVisible(true)
})
const onSoftReset = React.useCallback(() => {
flatListRef.current?.scrollToOffset({offset: 0})
multifeed.loadLatest()
resetPromptTimer()
setLoadPromptVisible(false)
resetMainScroll()
}, [flatListRef, resetMainScroll])
}, [
flatListRef,
resetMainScroll,
multifeed,
resetPromptTimer,
setLoadPromptVisible,
])
useFocusEffect(
React.useCallback(() => {
@ -99,11 +114,11 @@ export const FeedsScreen = withAuthRequired(
hideOnScroll
renderButton={renderHeaderBtn}
/>
{isScrolledDown ? (
{isScrolledDown || loadPromptVisible ? (
<LoadLatestBtn
onPress={onSoftReset}
label="Scroll to top"
showIndicator={false}
label="Load latest posts"
showIndicator={loadPromptVisible}
/>
) : null}
<FAB

View file

@ -52,8 +52,15 @@ export const HomeScreen = withAuthRequired(
model.setup()
feeds.push(model)
}
pagerRef.current?.setPage(0)
setCustomFeeds(feeds)
}, [store, store.me.savedFeeds.pinned, customFeeds, setCustomFeeds])
}, [
store,
store.me.savedFeeds.pinned,
customFeeds,
setCustomFeeds,
pagerRef,
])
useFocusEffect(
React.useCallback(() => {