mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 11:47:24 +01:00
Makes sure only one npub is logged in at the same time
This commit is contained in:
@@ -156,12 +156,9 @@ object LocalPreferences {
|
||||
private val prefsDirPath: String
|
||||
get() = "${Amethyst.instance.filesDir.parent}/shared_prefs/"
|
||||
|
||||
private suspend fun addAccount(npub: AccountInfo) {
|
||||
val accounts = savedAccounts().toMutableList()
|
||||
if (npub !in accounts) {
|
||||
accounts.add(npub)
|
||||
updateSavedAccounts(accounts)
|
||||
}
|
||||
private suspend fun addAccount(accInfo: AccountInfo) {
|
||||
val accounts = savedAccounts().filter { it.npub != accInfo.npub }.plus(accInfo)
|
||||
updateSavedAccounts(accounts)
|
||||
}
|
||||
|
||||
private suspend fun setCurrentAccount(account: Account) = withContext(Dispatchers.IO) {
|
||||
@@ -183,10 +180,8 @@ object LocalPreferences {
|
||||
* Removes the account from the app level shared preferences
|
||||
*/
|
||||
private suspend fun removeAccount(accountInfo: AccountInfo) {
|
||||
val accounts = savedAccounts().toMutableList()
|
||||
if (accounts.remove(accountInfo)) {
|
||||
updateSavedAccounts(accounts)
|
||||
}
|
||||
val accounts = savedAccounts().filter { it.npub != accountInfo.npub }
|
||||
updateSavedAccounts(accounts)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user