mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Make sure accounts are updated
This commit is contained in:
parent
8f85aed7e8
commit
ae669971c9
2 changed files with 23 additions and 1 deletions
|
@ -323,6 +323,17 @@ object AccountHelper {
|
|||
|
||||
recyclerView.setLinearListLayout(isHorizontal = true)
|
||||
|
||||
val currentAccount = DataStoreHelper.accounts.firstOrNull {
|
||||
it.keyIndex == DataStoreHelper.selectedKeyIndex
|
||||
} ?: getDefaultAccount(activity)
|
||||
|
||||
// We want to make sure the accounts are up-to-date
|
||||
viewModel.handleAccountSelect(
|
||||
currentAccount,
|
||||
activity,
|
||||
reloadForActivity = true
|
||||
)
|
||||
|
||||
activity.observe(viewModel.accounts) { liveAccounts ->
|
||||
recyclerView.adapter = AccountAdapter(
|
||||
liveAccounts,
|
||||
|
|
|
@ -89,8 +89,19 @@ class AccountViewModel : ViewModel() {
|
|||
fun handleAccountSelect(
|
||||
account: DataStoreHelper.Account,
|
||||
context: Context,
|
||||
forStartup: Boolean = false
|
||||
forStartup: Boolean = false,
|
||||
reloadForActivity: Boolean = false
|
||||
) {
|
||||
if (reloadForActivity) {
|
||||
val currentAccount = DataStoreHelper.accounts.firstOrNull {
|
||||
it.keyIndex == DataStoreHelper.selectedKeyIndex
|
||||
}
|
||||
|
||||
_accounts.postValue(getAccounts(context))
|
||||
_selectedKeyIndex.postValue(getAccounts(context).indexOf(currentAccount))
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the selected account has a lock PIN set
|
||||
if (account.lockPin != null) {
|
||||
// The selected account has a PIN set, prompt the user to enter the PIN
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue