fix(nests): clear NestBridge on logout and account switch
NestBridge holds a process-singleton AccountViewModel reference so NestActivity (separately tasked) can read the active account without serialising a NostrSigner through an Intent extra. The bridge's doc promised it'd be cleared on logout / account switch but no call site existed — so the audio-room activity could pick up a stale AccountViewModel from the previous session and sign with the old key after an account swap. Wire NestBridge.clear() into both transition points in AccountSessionManager: switchUserSync (always) and logOff (only when the current account is being torn down). https://claude.ai/code/session_01DMeCvWyBYVVVPez2hwqCs4
This commit is contained in:
@@ -331,6 +331,12 @@ class AccountSessionManager(
|
|||||||
accountInfo: AccountInfo,
|
accountInfo: AccountInfo,
|
||||||
routeBuilder: ((account: Account) -> Route?)? = null,
|
routeBuilder: ((account: Account) -> Route?)? = null,
|
||||||
) {
|
) {
|
||||||
|
// The Nest audio-room activity reads the active AccountViewModel
|
||||||
|
// through a process-singleton bridge. Drop the previous user's
|
||||||
|
// ref before swapping so a stale ref can't survive into the new
|
||||||
|
// session — see [NestBridge].
|
||||||
|
com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.room.activity.NestBridge
|
||||||
|
.clear()
|
||||||
localPreferences.switchToAccount(accountInfo)
|
localPreferences.switchToAccount(accountInfo)
|
||||||
loginWithDefaultAccount(routeBuilder)
|
loginWithDefaultAccount(routeBuilder)
|
||||||
}
|
}
|
||||||
@@ -351,6 +357,11 @@ class AccountSessionManager(
|
|||||||
fun logOff(accountInfo: AccountInfo) {
|
fun logOff(accountInfo: AccountInfo) {
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
if (accountInfo.npub == currentAccountNPub()) {
|
if (accountInfo.npub == currentAccountNPub()) {
|
||||||
|
// Drop the Nest bridge ref before tearing down the
|
||||||
|
// current account so the audio-room activity can't
|
||||||
|
// pick up a stale AccountViewModel — see [NestBridge].
|
||||||
|
com.vitorpamplona.amethyst.ui.screen.loggedIn.nests.room.activity.NestBridge
|
||||||
|
.clear()
|
||||||
// log off and relogin with the 0 account
|
// log off and relogin with the 0 account
|
||||||
localPreferences.deleteAccount(accountInfo)
|
localPreferences.deleteAccount(accountInfo)
|
||||||
accountsCache.removeAccount(accountInfo.npub.bechToBytes().toHexKey())
|
accountsCache.removeAccount(accountInfo.npub.bechToBytes().toHexKey())
|
||||||
|
|||||||
Reference in New Issue
Block a user