diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index c6442de4..252be150 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -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); diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt index 05c68322..a43776dd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt @@ -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 diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt b/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt index 0d1ea37b..61ce076a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt @@ -37,9 +37,11 @@ class AccountManager @Inject constructor(db: AppDatabase) { @Volatile var activeAccount: AccountEntity? = null + private set var accounts: MutableList = mutableListOf() private set + private val accountDao: AccountDao = db.accountDao() init {