Make homepage preferences account specific (#647)

* Make homepage preferences account specific

* Fix accidentally removed whitespace

* Fix in setkey
This commit is contained in:
Luna712 2023-10-03 11:25:31 -06:00 committed by GitHub
parent 462073bd74
commit cc00e73e16
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,7 +377,7 @@ class HomeFragment : Fragment() {
var currentApiName = selectedApiName var currentApiName = selectedApiName
var currentValidApis: MutableList<MainAPI> = mutableListOf() 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 } } ?.mapNotNull { listName -> TvType.values().firstOrNull { it.name == listName } }
?.toMutableList() ?.toMutableList()
?: mutableListOf(TvType.Movie, TvType.TvSeries) ?: mutableListOf(TvType.Movie, TvType.TvSeries)
@ -408,7 +408,7 @@ class HomeFragment : Fragment() {
} }
fun updateList() { fun updateList() {
this.setKey(HOME_PREF_HOMEPAGE, preSelectedTypes) this.setKey("${DataStoreHelper.currentAccount}/$HOME_PREF_HOMEPAGE", preSelectedTypes)
arrayAdapter.clear() arrayAdapter.clear()
currentValidApis = validAPIs.filter { api -> currentValidApis = validAPIs.filter { api ->

View file

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