Fix pinned feeds mutation issue (#2016)
parent
0b2c85b967
commit
bb9d340d42
|
@ -252,7 +252,6 @@ export function usePinnedFeedsInfos(): FeedSourceInfo[] {
|
||||||
FOLLOWING_FEED_STUB,
|
FOLLOWING_FEED_STUB,
|
||||||
])
|
])
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const pinnedFeedsKey = JSON.stringify(preferences?.feeds?.pinned)
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!preferences?.feeds?.pinned) return
|
if (!preferences?.feeds?.pinned) return
|
||||||
|
@ -299,13 +298,7 @@ export function usePinnedFeedsInfos(): FeedSourceInfo[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchFeedInfo()
|
fetchFeedInfo()
|
||||||
}, [
|
}, [queryClient, setTabs, preferences?.feeds?.pinned])
|
||||||
queryClient,
|
|
||||||
setTabs,
|
|
||||||
preferences?.feeds?.pinned,
|
|
||||||
// ensure we react to re-ordering
|
|
||||||
pinnedFeedsKey,
|
|
||||||
])
|
|
||||||
|
|
||||||
return tabs
|
return tabs
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,7 @@ function HomeScreenReady({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return feeds
|
return feeds
|
||||||
// TODO careful, needed to disabled this -esb
|
}, [preferences.feeds.pinned])
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [preferences.feeds.pinned, pinnedFeedOrderKey])
|
|
||||||
|
|
||||||
const homeFeedParams = React.useMemo<FeedParams>(() => {
|
const homeFeedParams = React.useMemo<FeedParams>(() => {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -185,7 +185,8 @@ function ListItem({
|
||||||
queryClient.getQueryData<UsePreferencesQueryResponse>(
|
queryClient.getQueryData<UsePreferencesQueryResponse>(
|
||||||
preferencesQueryKey,
|
preferencesQueryKey,
|
||||||
)?.feeds
|
)?.feeds
|
||||||
const pinned = feeds?.pinned ?? []
|
// create new array, do not mutate
|
||||||
|
const pinned = feeds?.pinned ? [...feeds.pinned] : []
|
||||||
const index = pinned.indexOf(feedUri)
|
const index = pinned.indexOf(feedUri)
|
||||||
|
|
||||||
if (index === -1 || index === 0) return
|
if (index === -1 || index === 0) return
|
||||||
|
@ -210,7 +211,8 @@ function ListItem({
|
||||||
queryClient.getQueryData<UsePreferencesQueryResponse>(
|
queryClient.getQueryData<UsePreferencesQueryResponse>(
|
||||||
preferencesQueryKey,
|
preferencesQueryKey,
|
||||||
)?.feeds
|
)?.feeds
|
||||||
const pinned = feeds?.pinned ?? []
|
// create new array, do not mutate
|
||||||
|
const pinned = feeds?.pinned ? [...feeds.pinned] : []
|
||||||
const index = pinned.indexOf(feedUri)
|
const index = pinned.indexOf(feedUri)
|
||||||
|
|
||||||
if (index === -1 || index >= pinned.length - 1) return
|
if (index === -1 || index >= pinned.length - 1) return
|
||||||
|
|
Loading…
Reference in New Issue