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
This commit is contained in:
Paul Frazee
2024-01-04 17:36:27 -08:00
committed by GitHub
parent 8a4a8af61c
commit db62f27241
4 changed files with 8 additions and 2 deletions
@@ -15,6 +15,7 @@ import {useMutedThreads} from '#/state/muted-threads'
import {RQKEY as RQKEY_NOTIFS} from './feed'
import {logger} from '#/logger'
import {truncateAndInvalidate} from '../util'
import {AppState} from 'react-native'
const UPDATE_INTERVAL = 30 * 1e3 // 30sec
@@ -97,6 +98,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
async checkUnread({invalidate}: {invalidate?: boolean} = {}) {
try {
if (!getAgent().session) return
if (AppState.currentState !== 'active') {
return
}
// count
const page = await fetchPage({