From 0b2c85b967ea7a2dd18261773449260b80004423 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 28 Nov 2023 11:04:15 -0600 Subject: [PATCH] Fix pinned feeds re-ordering (#2014) --- src/view/screens/Home.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 28f01b68..476c69fc 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -40,6 +40,12 @@ function HomeScreenReady({ const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() const [selectedPage, setSelectedPage] = React.useState(0) + /** + * Used to ensure that we re-compute `customFeeds` AND force a re-render of + * the pager with the new order of feeds. + */ + const pinnedFeedOrderKey = JSON.stringify(preferences.feeds.pinned) + const customFeeds = React.useMemo(() => { const pinned = preferences.feeds.pinned const feeds: FeedDescriptor[] = [] @@ -51,7 +57,9 @@ function HomeScreenReady({ } } return feeds - }, [preferences.feeds.pinned]) + // TODO careful, needed to disabled this -esb + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [preferences.feeds.pinned, pinnedFeedOrderKey]) const homeFeedParams = React.useMemo(() => { return { @@ -83,7 +91,6 @@ function HomeScreenReady({ emitSoftReset() }, []) - // TODO(pwi) may need this in public view const onPageScrollStateChanged = React.useCallback( (state: 'idle' | 'dragging' | 'settling') => { if (state === 'dragging') { @@ -118,6 +125,7 @@ function HomeScreenReady({ return hasSession ? (