Make sure the active account is always correctly saved to database (#3720)
Fixes #3702
This commit is contained in:
parent
3698c72109
commit
6e06e656b4
3 changed files with 4 additions and 12 deletions
|
@ -212,15 +212,8 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: This changes the accountManager's activeAccount property, but does not do any
|
||||
// of the work that AccountManager.setActiveAccount() does. In particular:
|
||||
//
|
||||
// - The current active account is not saved
|
||||
// - The account passed as parameter here goes not have its `isActive` property set
|
||||
//
|
||||
// Is that deliberate? Or is this a bug?
|
||||
public void openAsAccount(@NonNull String url, @NonNull AccountEntity account) {
|
||||
accountManager.setActiveAccount(account);
|
||||
accountManager.setActiveAccount(account.getId());
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.putExtra(MainActivity.REDIRECT_URL, url);
|
||||
|
|
|
@ -46,11 +46,8 @@ class SearchViewModel @Inject constructor(
|
|||
|
||||
var currentQuery: String = ""
|
||||
|
||||
var activeAccount: AccountEntity?
|
||||
val activeAccount: AccountEntity?
|
||||
get() = accountManager.activeAccount
|
||||
set(value) {
|
||||
accountManager.activeAccount = value
|
||||
}
|
||||
|
||||
val mediaPreviewEnabled = activeAccount?.mediaPreviewEnabled ?: false
|
||||
val alwaysShowSensitiveMedia = activeAccount?.alwaysShowSensitiveMedia ?: false
|
||||
|
|
|
@ -37,9 +37,11 @@ class AccountManager @Inject constructor(db: AppDatabase) {
|
|||
|
||||
@Volatile
|
||||
var activeAccount: AccountEntity? = null
|
||||
private set
|
||||
|
||||
var accounts: MutableList<AccountEntity> = mutableListOf()
|
||||
private set
|
||||
|
||||
private val accountDao: AccountDao = db.accountDao()
|
||||
|
||||
init {
|
||||
|
|
Loading…
Reference in a new issue