Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Reduce web requests (#2420)

* Stop auto-refetching app passwords and invites on an interval

* Don't poll for posts or notifs if the app/tab isnt focused

authored by

Paul Frazee and committed by
GitHub
db62f272 8a4a8af6

+8 -2
-1
src/state/queries/app-passwords.ts
··· 9 9 export function useAppPasswordsQuery() { 10 10 return useQuery({ 11 11 staleTime: STALE.MINUTES.FIVE, 12 - refetchInterval: STALE.MINUTES.ONE, 13 12 queryKey: RQKEY(), 14 13 queryFn: async () => { 15 14 const res = await getAgent().com.atproto.server.listAppPasswords({})
-1
src/state/queries/invites.ts
··· 16 16 export function useInviteCodesQuery() { 17 17 return useQuery({ 18 18 staleTime: STALE.MINUTES.FIVE, 19 - refetchInterval: STALE.MINUTES.FIVE, 20 19 queryKey: ['inviteCodes'], 21 20 queryFn: async () => { 22 21 const res = await getAgent()
+4
src/state/queries/notifications/unread.tsx
··· 15 15 import {RQKEY as RQKEY_NOTIFS} from './feed' 16 16 import {logger} from '#/logger' 17 17 import {truncateAndInvalidate} from '../util' 18 + import {AppState} from 'react-native' 18 19 19 20 const UPDATE_INTERVAL = 30 * 1e3 // 30sec 20 21 ··· 97 98 async checkUnread({invalidate}: {invalidate?: boolean} = {}) { 98 99 try { 99 100 if (!getAgent().session) return 101 + if (AppState.currentState !== 'active') { 102 + return 103 + } 100 104 101 105 // count 102 106 const page = await fetchPage({
+4
src/state/queries/post-feed.ts
··· 1 1 import React, {useCallback, useEffect, useRef} from 'react' 2 + import {AppState} from 'react-native' 2 3 import {AppBskyFeedDefs, AppBskyFeedPost, PostModeration} from '@atproto/api' 3 4 import { 4 5 useInfiniteQuery, ··· 311 312 export async function pollLatest(page: FeedPage | undefined) { 312 313 if (!page) { 313 314 return false 315 + } 316 + if (AppState.currentState !== 'active') { 317 + return 314 318 } 315 319 316 320 logger.debug('usePostFeedQuery: pollLatest')