diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/state/queries/notifications/feed.ts | 1 | ||||
-rw-r--r-- | src/state/queries/notifications/unread.tsx | 4 | ||||
-rw-r--r-- | src/state/queries/notifications/util.ts | 16 | ||||
-rw-r--r-- | src/view/com/composer/Composer.tsx | 19 | ||||
-rw-r--r-- | src/view/screens/Profile.tsx | 1 |
5 files changed, 17 insertions, 24 deletions
diff --git a/src/state/queries/notifications/feed.ts b/src/state/queries/notifications/feed.ts index b6aa3d753..1610fc0bf 100644 --- a/src/state/queries/notifications/feed.ts +++ b/src/state/queries/notifications/feed.ts @@ -76,6 +76,7 @@ export function useNotificationFeedQuery(opts?: {enabled?: boolean}) { queryClient, moderationOpts, threadMutes, + fetchAdditionalData: true, }) } diff --git a/src/state/queries/notifications/unread.tsx b/src/state/queries/notifications/unread.tsx index ba38463f2..a189f20e4 100644 --- a/src/state/queries/notifications/unread.tsx +++ b/src/state/queries/notifications/unread.tsx @@ -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 = diff --git a/src/state/queries/notifications/util.ts b/src/state/queries/notifications/util.ts index 48e1b8dd8..9fb25867a 100644 --- a/src/state/queries/notifications/util.ts +++ b/src/state/queries/notifications/util.ts @@ -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 + } } } } diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 97d443451..f510be0be 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -14,7 +14,7 @@ import { import {useSafeAreaInsets} from 'react-native-safe-area-context' import LinearGradient from 'react-native-linear-gradient' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' -import {AppBskyFeedGetPosts, RichText} from '@atproto/api' +import {RichText} from '@atproto/api' import {useAnalytics} from 'lib/analytics/analytics' import {useIsKeyboardVisible} from 'lib/hooks/useIsKeyboardVisible' import {ExternalEmbed} from './ExternalEmbed' @@ -60,7 +60,6 @@ import { import {useSession, getAgent} from '#/state/session' import {useProfileQuery} from '#/state/queries/profile' import {useComposerControls} from '#/state/shell/composer' -import {until} from '#/lib/async/until' import {emitPostCreated} from '#/state/events' import {ThreadgateSetting} from '#/state/queries/threadgate' @@ -246,9 +245,7 @@ export const ComposePost = observer(function ComposePost({ if (replyTo && replyTo.uri) track('Post:Reply') } if (postUri && !replyTo) { - whenAppViewReady(postUri).then(() => { - emitPostCreated() - }) + emitPostCreated() } setLangPrefs.savePostLanguageToHistory() onPost?.() @@ -553,15 +550,3 @@ const styles = StyleSheet.create({ borderTopWidth: 1, }, }) - -async function whenAppViewReady(uri: string) { - await until( - 5, // 5 tries - 1e3, // 1s delay between tries - (res: AppBskyFeedGetPosts.Response) => !!res.data.posts[0], - () => - getAgent().getPosts({ - uris: [uri], - }), - ) -} diff --git a/src/view/screens/Profile.tsx b/src/view/screens/Profile.tsx index e019c4ede..b7dac8c6d 100644 --- a/src/view/screens/Profile.tsx +++ b/src/view/screens/Profile.tsx @@ -441,7 +441,6 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>( testID="postsFeed" enabled={isFocused} feed={feed} - pollInterval={30e3} scrollElRef={scrollElRef} onHasNew={setHasNew} onScroll={onScroll} |