mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Make homepage preferences account specific (#647)
* Make homepage preferences account specific * Fix accidentally removed whitespace * Fix in setkey
This commit is contained in:
parent
462073bd74
commit
cc00e73e16
2 changed files with 5 additions and 5 deletions
|
@ -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 ->
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue