mirror of
https://github.com/tuskyapp/Tusky
synced 2025-01-06 13:57:43 +01:00
fix ConcurrentModificationException when sorting accounts
This commit is contained in:
parent
d371074d2a
commit
83dc45be35
@ -160,7 +160,8 @@ class AccountManager(db: AppDatabase) {
|
|||||||
* @return an immutable list of all accounts in the database with the active account first
|
* @return an immutable list of all accounts in the database with the active account first
|
||||||
*/
|
*/
|
||||||
fun getAllAccountsOrderedByActive(): List<AccountEntity> {
|
fun getAllAccountsOrderedByActive(): List<AccountEntity> {
|
||||||
accounts.sortWith(Comparator { l, r ->
|
val accountsCopy = accounts.toMutableList()
|
||||||
|
accountsCopy.sortWith(Comparator { l, r ->
|
||||||
when {
|
when {
|
||||||
l.isActive && !r.isActive -> -1
|
l.isActive && !r.isActive -> -1
|
||||||
r.isActive && !l.isActive -> 1
|
r.isActive && !l.isActive -> 1
|
||||||
@ -168,7 +169,7 @@ class AccountManager(db: AppDatabase) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return accounts.toList()
|
return accountsCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user