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 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)
@ -408,7 +408,7 @@ class HomeFragment : Fragment() {
}
fun updateList() {
this.setKey(HOME_PREF_HOMEPAGE, preSelectedTypes)
this.setKey("${DataStoreHelper.currentAccount}/$HOME_PREF_HOMEPAGE", preSelectedTypes)
arrayAdapter.clear()
currentValidApis = validAPIs.filter { api ->

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)