BugFix for restarting the relay connection when switching accounts after Amber's integration.

This commit is contained in:
Vitor Pamplona 2023-09-24 18:12:50 -04:00
parent f4da2ae6be
commit 7071174aed
2 changed files with 8 additions and 1 deletions

View File

@ -142,6 +142,13 @@ object ServiceManager {
LocalCache.pruneExpiredEvents()
}
}
fun restartIfDifferentAccount(account: Account, context: Context) {
if (this.account != account) {
pause()
start(account, context)
}
}
}
object SingletonDiskCache {

View File

@ -88,7 +88,7 @@ class AccountStateViewModel(val context: Context) : ViewModel() {
_accountContent.update { AccountState.LoggedInViewOnly(account) }
}
GlobalScope.launch(Dispatchers.IO) {
ServiceManager.start(account, context)
ServiceManager.restartIfDifferentAccount(account, context)
}
GlobalScope.launch(Dispatchers.Main) {
account.saveable.observeForever(saveListener)