Reduce polling when app is backgrounded (#4192)

zio/stable
Eric Bailey 2024-05-23 11:54:22 -05:00 committed by GitHub
parent d051614342
commit 9011c11eaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -4,7 +4,10 @@ import {nanoid} from 'nanoid/non-secure'
import {networkRetry} from '#/lib/async/retry'
import {logger} from '#/logger'
import {DEFAULT_POLL_INTERVAL} from '#/state/messages/events/const'
import {
BACKGROUND_POLL_INTERVAL,
DEFAULT_POLL_INTERVAL,
} from '#/state/messages/events/const'
import {
MessagesEventBusDispatch,
MessagesEventBusDispatchEvent,
@ -287,6 +290,9 @@ export class MessagesEventBus {
const lowest = Math.min(DEFAULT_POLL_INTERVAL, ...requested)
return lowest
}
case MessagesEventBusStatus.Backgrounded: {
return BACKGROUND_POLL_INTERVAL
}
default:
return DEFAULT_POLL_INTERVAL
}

View File

@ -1 +1,2 @@
export const DEFAULT_POLL_INTERVAL = 20e3
export const BACKGROUND_POLL_INTERVAL = 60e3