mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-11 08:47:33 +00:00
LocalPreferences.setDefaultAccount called setCurrentAccount before saveToEncryptedStorage. setCurrentAccount emits the new list onto the savedAccounts MutableStateFlow, which AlwaysOnNotificationServiceManager collects and reacts to by calling loadAccountConfigFromEncryptedStorage for every saved account — including the just-added one. That call hit encryptedPreferences(newNpub) before NOSTR_PUBKEY had been written, got null, and cached the null in cachedAccounts. cachedAccounts is a process-lifetime map, so the poisoned entry survived the eventual disk write. Every subsequent switchUser to that account took the cached null path, fell through to requestLoginUI(), and AccountScreen rendered LoggedOffSetup — the onboarding screen with TOS unchecked, asking the user to re-do the Amber handshake. Write the per-npub file first, then seed the cache with the in-memory AccountSettings, then publish onto the savedAccounts flow. Also stop caching null returns in loadAccountConfigFromEncryptedStorage so any future racy reader can't poison the cache either.