// Background-sync decision layer — pure, on top of `@voltro/react-native`. // // The framework owns the DECISION (should this trigger actually sync, given // what's in flight + when we last ran); the OS wiring (AppState / interval / // background-fetch) is the screen's. Keeping the decision here + pure means a // screen never re-implements the gate, and the gate is unit-testable. import { backgroundSyncReducer, initialBackgroundSyncState, shouldSync, type BackgroundSyncState, type ShouldSyncOptions, } from '@voltro/react-native' /** Sync every 5 minutes while foregrounded (matches `offlineFirstDefaults`). */ export const SYNC_OPTIONS: ShouldSyncOptions = { intervalMs: 5 * 60_000, enabled: true } /** * Should a trigger (foreground return, interval tick, manual pull) actually kick * a sync now? `force` bypasses the foreground + interval gates (a manual pull). */ export const planSync = ( state: BackgroundSyncState, now: number, force = false, ): boolean => shouldSync(state, now, SYNC_OPTIONS, force) export { backgroundSyncReducer, initialBackgroundSyncState } export type { BackgroundSyncState }