Apply feed preferences (react-query refactor) (#2040)
* Actually implement the feed tuners hook * Move feed-tuner pass into select() to have it apply immediately on change
This commit is contained in:
parent
3e1b2346ee
commit
a03f57c8c3
3 changed files with 102 additions and 85 deletions
|
@ -8,10 +8,7 @@ import {useQuery, useQueryClient, QueryClient} from '@tanstack/react-query'
|
|||
import {getAgent} from '#/state/session'
|
||||
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {
|
||||
findPostInQueryData as findPostInFeedQueryData,
|
||||
FeedPostSliceItem,
|
||||
} from './post-feed'
|
||||
import {findPostInQueryData as findPostInFeedQueryData} from './post-feed'
|
||||
import {findPostInQueryData as findPostInNotifsQueryData} from './notifications/feed'
|
||||
import {precacheThreadPosts as precacheResolvedUris} from './resolve-uri'
|
||||
|
||||
|
@ -93,7 +90,7 @@ export function usePostThreadQuery(uri: string | undefined) {
|
|||
{
|
||||
const item = findPostInFeedQueryData(queryClient, uri)
|
||||
if (item) {
|
||||
return feedItemToPlaceholderThread(item)
|
||||
return feedViewPostToPlaceholderThread(item)
|
||||
}
|
||||
}
|
||||
{
|
||||
|
@ -275,13 +272,15 @@ function threadNodeToPlaceholderThread(
|
|||
}
|
||||
}
|
||||
|
||||
function feedItemToPlaceholderThread(item: FeedPostSliceItem): ThreadNode {
|
||||
function feedViewPostToPlaceholderThread(
|
||||
item: AppBskyFeedDefs.FeedViewPost,
|
||||
): ThreadNode {
|
||||
return {
|
||||
type: 'post',
|
||||
_reactKey: item.post.uri,
|
||||
uri: item.post.uri,
|
||||
post: item.post,
|
||||
record: item.record,
|
||||
record: item.post.record as AppBskyFeedPost.Record, // validated in post-feed
|
||||
parent: undefined,
|
||||
replies: undefined,
|
||||
viewer: item.post.viewer,
|
||||
|
@ -291,7 +290,7 @@ function feedItemToPlaceholderThread(item: FeedPostSliceItem): ThreadNode {
|
|||
hasMore: false,
|
||||
showChildReplyLine: false,
|
||||
showParentReplyLine: false,
|
||||
isParentLoading: !!item.record.reply,
|
||||
isParentLoading: !!(item.post.record as AppBskyFeedPost.Record).reply,
|
||||
isChildLoading: !!item.post.replyCount,
|
||||
},
|
||||
}
|
||||
|
@ -305,7 +304,7 @@ function postViewToPlaceholderThread(
|
|||
_reactKey: post.uri,
|
||||
uri: post.uri,
|
||||
post: post,
|
||||
record: post.record as AppBskyFeedPost.Record, // validate in notifs
|
||||
record: post.record as AppBskyFeedPost.Record, // validated in notifs
|
||||
parent: undefined,
|
||||
replies: undefined,
|
||||
viewer: post.viewer,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue