DustBackupStateStore

@Singleton
class DustBackupStateStore @Inject constructor(context: Context)

SINGLE owner of the durable dust-backup choice — the tri-state {never-chosen / enabled / opted-out} that was previously two independent pref keys + two StateFlows hand-synced at five call sites inside WalletPanelViewModel. A singleton so the restore gate (a com.midnight.kuira.sdk.walletruntime.DustRestoreGate impl, which outlives any ViewModel) and the panel VM read/write the SAME live state: a gate-committed toggle is instantly visible to the UI, and the wallet's upload-time prefs supplier (com.midnight.kuira.sdk.MidnightWallet.walletBackupPrefsProvider) always reads current truth — no pushed snapshot to go stale.

Invariant (enforced here, not by caller discipline): enabled and optedOut are never both true.

Constructors

Link copied to clipboard
@Inject
constructor(context: Context)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val enabled: StateFlow<Boolean>

True → the user has dust cloud backup ENABLED — the durable committed toggle (consent granted + sync succeeded at least once, or restored from the wallet's cloud prefs). Drives the Switch position, never the live sync status.

Link copied to clipboard

The one-time backup-setup offer (a NEW wallet's onboarding step) was shown — never nag again; the BackupSection toggle stays as the manual path.

Link copied to clipboard
val optedOut: StateFlow<Boolean>

True → the user disabled dust cloud backup (#246 semantics: stop uploading).

Functions

Link copied to clipboard

The enable flow is starting: clear the opt-out now; commitEnabled lands on success.

Link copied to clipboard

Durable toggle ON (enable+sync succeeded, or the restore gate recovered the truth).

Link copied to clipboard

Durable opt-out (user disabled, or the restore gate mirrored a restored opt-out).

Link copied to clipboard

The blob-borne prefs snapshot the wallet's upload-time supplier reads.