Fix pinned feeds key
This commit is contained in:
+19
-20
@@ -238,23 +238,6 @@ const DISCOVER_FEED_STUB: FeedSourceInfo = {
|
|||||||
likeCount: 0,
|
likeCount: 0,
|
||||||
likeUri: '',
|
likeUri: '',
|
||||||
}
|
}
|
||||||
const PRIMARY_ALGO_STUB: FeedSourceInfo = {
|
|
||||||
type: 'feed',
|
|
||||||
displayName: 'For You',
|
|
||||||
uri: 'primary-algo',
|
|
||||||
route: {
|
|
||||||
href: '/',
|
|
||||||
name: 'For You',
|
|
||||||
params: {},
|
|
||||||
},
|
|
||||||
cid: '',
|
|
||||||
avatar: '',
|
|
||||||
description: new RichText({text: ''}),
|
|
||||||
creatorDid: '',
|
|
||||||
creatorHandle: '',
|
|
||||||
likeCount: 0,
|
|
||||||
likeUri: '',
|
|
||||||
}
|
|
||||||
|
|
||||||
const pinnedFeedInfosQueryKeyRoot = 'pinnedFeedsInfos'
|
const pinnedFeedInfosQueryKeyRoot = 'pinnedFeedsInfos'
|
||||||
|
|
||||||
@@ -283,6 +266,11 @@ export function usePinnedFeedsInfos() {
|
|||||||
queryKey: [
|
queryKey: [
|
||||||
pinnedFeedInfosQueryKeyRoot,
|
pinnedFeedInfosQueryKeyRoot,
|
||||||
(hasSession ? 'authed:' : 'unauthed:') + pinnedUris.join(','),
|
(hasSession ? 'authed:' : 'unauthed:') + pinnedUris.join(','),
|
||||||
|
`primary:${
|
||||||
|
preferences?.primaryAlgorithm.uri
|
||||||
|
? preferences?.primaryAlgorithm.uri
|
||||||
|
: 'none'
|
||||||
|
}`,
|
||||||
],
|
],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
let resolved = new Map()
|
let resolved = new Map()
|
||||||
@@ -323,6 +311,7 @@ export function usePinnedFeedsInfos() {
|
|||||||
// The returned result will have the original order.
|
// The returned result will have the original order.
|
||||||
let result = [hasSession ? HOME_FEED_STUB : DISCOVER_FEED_STUB]
|
let result = [hasSession ? HOME_FEED_STUB : DISCOVER_FEED_STUB]
|
||||||
|
|
||||||
|
let primaryAlgoPromise = Promise.resolve()
|
||||||
if (
|
if (
|
||||||
isPrimaryAlgoExperimentEnabled &&
|
isPrimaryAlgoExperimentEnabled &&
|
||||||
hasSession &&
|
hasSession &&
|
||||||
@@ -331,17 +320,27 @@ export function usePinnedFeedsInfos() {
|
|||||||
const {enabled, uri} = preferences.primaryAlgorithm
|
const {enabled, uri} = preferences.primaryAlgorithm
|
||||||
// ONLY add the primary algo if we have a URI set
|
// ONLY add the primary algo if we have a URI set
|
||||||
if (enabled && uri) {
|
if (enabled && uri) {
|
||||||
result = [PRIMARY_ALGO_STUB, HOME_FEED_STUB]
|
primaryAlgoPromise = getAgent()
|
||||||
|
.app.bsky.feed.getFeedGenerator({
|
||||||
|
feed: uri,
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
result.unshift(hydrateFeedGenerator(res.data.view))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.allSettled([feedsPromise, ...listsPromises])
|
await Promise.allSettled([
|
||||||
|
feedsPromise,
|
||||||
|
primaryAlgoPromise,
|
||||||
|
...listsPromises,
|
||||||
|
])
|
||||||
for (let pinnedUri of pinnedUris) {
|
for (let pinnedUri of pinnedUris) {
|
||||||
if (resolved.has(pinnedUri)) {
|
if (resolved.has(pinnedUri)) {
|
||||||
result.push(resolved.get(pinnedUri))
|
result.push(resolved.get(pinnedUri))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(result)
|
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user