handle failed custom feeds on home screen (#1012)

* handle failed custom feeds on home screen

* remove unnecessary edit

* make sure edits to pinned feeds are handled and reloaded

* fix lint
zio/stable
Eric Bailey 2023-07-17 17:31:56 -05:00 committed by GitHub
parent bfed96bd7b
commit aa4b79e77a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -36,13 +36,17 @@ export const HomeScreen = withAuthRequired(
const pagerRef = React.useRef<PagerRef>(null) const pagerRef = React.useRef<PagerRef>(null)
const [selectedPage, setSelectedPage] = React.useState(0) const [selectedPage, setSelectedPage] = React.useState(0)
const [customFeeds, setCustomFeeds] = React.useState<PostsFeedModel[]>([]) const [customFeeds, setCustomFeeds] = React.useState<PostsFeedModel[]>([])
const [requestedCustomFeeds, setRequestedCustomFeeds] = React.useState<
string[]
>([])
React.useEffect(() => { React.useEffect(() => {
const {pinned} = store.me.savedFeeds const {pinned} = store.me.savedFeeds
if ( if (
isEqual( isEqual(
pinned.map(p => p.uri), pinned.map(p => p.uri),
customFeeds.map(f => (f.params as GetCustomFeed.QueryParams).feed), requestedCustomFeeds,
) )
) { ) {
// no changes // no changes
@ -57,12 +61,15 @@ export const HomeScreen = withAuthRequired(
} }
pagerRef.current?.setPage(0) pagerRef.current?.setPage(0)
setCustomFeeds(feeds) setCustomFeeds(feeds)
setRequestedCustomFeeds(pinned.map(p => p.uri))
}, [ }, [
store, store,
store.me.savedFeeds.pinned, store.me.savedFeeds.pinned,
customFeeds, customFeeds,
setCustomFeeds, setCustomFeeds,
pagerRef, pagerRef,
requestedCustomFeeds,
setRequestedCustomFeeds,
]) ])
useFocusEffect( useFocusEffect(