Additional reductions in request traffic (#2169)
* Dont poll for new content on profiles * Drop the whenAppReady query after new post to reduce traffic overhead * Reduce getPosts calls in notifs to only use them when needed
This commit is contained in:
parent
ab04074197
commit
99cf6b626f
5 changed files with 17 additions and 24 deletions
|
@ -76,6 +76,7 @@ export function useNotificationFeedQuery(opts?: {enabled?: boolean}) {
|
|||
queryClient,
|
||||
moderationOpts,
|
||||
threadMutes,
|
||||
fetchAdditionalData: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||
queryClient,
|
||||
moderationOpts,
|
||||
threadMutes,
|
||||
|
||||
// only fetch subjects when the page is going to be used
|
||||
// in the notifications query, otherwise skip it
|
||||
fetchAdditionalData: !!invalidate,
|
||||
})
|
||||
const unreadCount = countUnread(page)
|
||||
const unreadCountStr =
|
||||
|
|
|
@ -27,12 +27,14 @@ export async function fetchPage({
|
|||
queryClient,
|
||||
moderationOpts,
|
||||
threadMutes,
|
||||
fetchAdditionalData,
|
||||
}: {
|
||||
cursor: string | undefined
|
||||
limit: number
|
||||
queryClient: QueryClient
|
||||
moderationOpts: ModerationOpts | undefined
|
||||
threadMutes: string[]
|
||||
fetchAdditionalData: boolean
|
||||
}): Promise<FeedPage> {
|
||||
const res = await getAgent().listNotifications({
|
||||
limit,
|
||||
|
@ -49,12 +51,14 @@ export async function fetchPage({
|
|||
|
||||
// we fetch subjects of notifications (usually posts) now instead of lazily
|
||||
// in the UI to avoid relayouts
|
||||
const subjects = await fetchSubjects(notifsGrouped)
|
||||
for (const notif of notifsGrouped) {
|
||||
if (notif.subjectUri) {
|
||||
notif.subject = subjects.get(notif.subjectUri)
|
||||
if (notif.subject) {
|
||||
precacheResolvedUri(queryClient, notif.subject.author) // precache the handle->did resolution
|
||||
if (fetchAdditionalData) {
|
||||
const subjects = await fetchSubjects(notifsGrouped)
|
||||
for (const notif of notifsGrouped) {
|
||||
if (notif.subjectUri) {
|
||||
notif.subject = subjects.get(notif.subjectUri)
|
||||
if (notif.subject) {
|
||||
precacheResolvedUri(queryClient, notif.subject.author) // precache the handle->did resolution
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue