Skip to content

Send files directly between devices over the internet - no cloud storage, no size limits.

557 B
Raw Blame
import { AppState, type AppStateStatus } from 'react-native'
import { setAppActive } from '@altersend/domain'

let started = false
let subscription: { remove: () => void } | null = null

export function startAppStateBridge(): () => void {
  if (started) return () => {}
  started = true

  setAppActive(AppState.currentState === 'active')

  subscription = AppState.addEventListener('change', (next: AppStateStatus) => {
    setAppActive(next === 'active')
  })

  return () => {
    started = false
    subscription?.remove()
    subscription = null
  }
}