Fix crash in Feeds and Starter Packs (#4616)
* Remove useless check * Fix the bug by only adding resolved feeds/lists * Clarify the purpose of the count fieldzio/stable
parent
873d91d466
commit
f64245c1fb
|
@ -41,11 +41,7 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
|
||||||
limit: 30,
|
limit: 30,
|
||||||
})
|
})
|
||||||
const popularFeeds = popularFeedsPages?.pages.flatMap(p => p.feeds) ?? []
|
const popularFeeds = popularFeedsPages?.pages.flatMap(p => p.feeds) ?? []
|
||||||
|
const suggestedFeeds = savedFeeds.concat(
|
||||||
const suggestedFeeds =
|
|
||||||
savedFeeds.length === 0
|
|
||||||
? popularFeeds
|
|
||||||
: savedFeeds.concat(
|
|
||||||
popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)),
|
popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -509,6 +509,7 @@ export function useSavedFeeds() {
|
||||||
placeholderData: previousData => {
|
placeholderData: previousData => {
|
||||||
return (
|
return (
|
||||||
previousData || {
|
previousData || {
|
||||||
|
// The likely count before we try to resolve them.
|
||||||
count: savedItems.length,
|
count: savedItems.length,
|
||||||
feeds: [],
|
feeds: [],
|
||||||
}
|
}
|
||||||
|
@ -556,28 +557,39 @@ export function useSavedFeeds() {
|
||||||
precacheList(queryClient, list)
|
precacheList(queryClient, list)
|
||||||
})
|
})
|
||||||
|
|
||||||
const res: SavedFeedItem[] = savedItems.map(s => {
|
const result: SavedFeedItem[] = []
|
||||||
if (s.type === 'timeline') {
|
for (let savedItem of savedItems) {
|
||||||
return {
|
if (savedItem.type === 'timeline') {
|
||||||
|
result.push({
|
||||||
type: 'timeline',
|
type: 'timeline',
|
||||||
config: s,
|
config: savedItem,
|
||||||
view: undefined,
|
view: undefined,
|
||||||
|
})
|
||||||
|
} else if (savedItem.type === 'feed') {
|
||||||
|
const resolvedFeed = resolvedFeeds.get(savedItem.value)
|
||||||
|
if (resolvedFeed) {
|
||||||
|
result.push({
|
||||||
|
type: 'feed',
|
||||||
|
config: savedItem,
|
||||||
|
view: resolvedFeed,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else if (savedItem.type === 'list') {
|
||||||
|
const resolvedList = resolvedLists.get(savedItem.value)
|
||||||
|
if (resolvedList) {
|
||||||
|
result.push({
|
||||||
|
type: 'list',
|
||||||
|
config: savedItem,
|
||||||
|
view: resolvedList,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: s.type,
|
// By this point we know the real count.
|
||||||
config: s,
|
count: result.length,
|
||||||
view:
|
feeds: result,
|
||||||
s.type === 'feed'
|
|
||||||
? resolvedFeeds.get(s.value)
|
|
||||||
: resolvedLists.get(s.value),
|
|
||||||
}
|
|
||||||
}) as SavedFeedItem[]
|
|
||||||
|
|
||||||
return {
|
|
||||||
count: savedItems.length,
|
|
||||||
feeds: res,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue