Make homepage preferences account specific

This commit is contained in:
Luna712 2023-10-03 11:02:08 -06:00 committed by GitHub
parent 462073bd74
commit 5f98b9a139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -377,13 +377,13 @@ class HomeFragment : Fragment() {
var currentApiName = selectedApiName
var currentValidApis: MutableList<MainAPI> = mutableListOf()
val preSelectedTypes = this.getKey<List<String>>(HOME_PREF_HOMEPAGE)
val preSelectedTypes = this.getKey<List<String>>("${DataStoreHelper.currentAccount}/$HOME_PREF_HOMEPAGE")
?.mapNotNull { listName -> TvType.values().firstOrNull { it.name == listName } }
?.toMutableList()
?: mutableListOf(TvType.Movie, TvType.TvSeries)
binding.cancelBtt.setOnClickListener {
dialog.dismissSafe()
dialog.dismissSafe()
}
binding.applyBtt.setOnClickListener {

View file

@ -171,7 +171,7 @@ class HomeViewModel : ViewModel() {
if (currentWatchTypes.size <= 0) {
setKey(
HOME_BOOKMARK_VALUE_LIST,
"${DataStoreHelper.currentAccount}/$HOME_BOOKMARK_VALUE_LIST",
intArrayOf()
)
_availableWatchStatusTypes.postValue(setOf<WatchType>() to setOf())
@ -182,7 +182,7 @@ class HomeViewModel : ViewModel() {
val watchPrefNotNull = preferredWatchStatus ?: EnumSet.of(currentWatchTypes.first())
//if (currentWatchTypes.any { watchPrefNotNull.contains(it) }) watchPrefNotNull else listOf(currentWatchTypes.first())
setKey(
HOME_BOOKMARK_VALUE_LIST,
"${DataStoreHelper.currentAccount}/$HOME_BOOKMARK_VALUE_LIST",
watchPrefNotNull.map { it.internalId }.toIntArray()
)
_availableWatchStatusTypes.postValue(
@ -463,7 +463,7 @@ class HomeViewModel : ViewModel() {
fun loadStoredData() {
val list = EnumSet.noneOf(WatchType::class.java)
getKey<IntArray>(HOME_BOOKMARK_VALUE_LIST)?.map { WatchType.fromInternalId(it) }?.let {
getKey<IntArray>("${DataStoreHelper.currentAccount}/$HOME_BOOKMARK_VALUE_LIST")?.map { WatchType.fromInternalId(it) }?.let {
list.addAll(it)
}
loadStoredData(list)