mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Make search prefs account specific (#640)
This commit is contained in:
parent
08060314ad
commit
462073bd74
1 changed files with 6 additions and 6 deletions
|
@ -194,7 +194,7 @@ class SearchFragment : Fragment() {
|
||||||
validAPIs.flatMap { api -> api.supportedTypes }.distinct()
|
validAPIs.flatMap { api -> api.supportedTypes }.distinct()
|
||||||
) { list ->
|
) { list ->
|
||||||
if (selectedSearchTypes.toSet() != list.toSet()) {
|
if (selectedSearchTypes.toSet() != list.toSet()) {
|
||||||
setKey(SEARCH_PREF_TAGS, selectedSearchTypes)
|
setKey("$currentAccount/$SEARCH_PREF_TAGS", selectedSearchTypes)
|
||||||
selectedSearchTypes.clear()
|
selectedSearchTypes.clear()
|
||||||
selectedSearchTypes.addAll(list)
|
selectedSearchTypes.addAll(list)
|
||||||
search(binding?.mainSearch?.query?.toString())
|
search(binding?.mainSearch?.query?.toString())
|
||||||
|
@ -236,7 +236,7 @@ class SearchFragment : Fragment() {
|
||||||
context?.let { ctx ->
|
context?.let { ctx ->
|
||||||
val validAPIs = ctx.filterProviderByPreferredMedia()
|
val validAPIs = ctx.filterProviderByPreferredMedia()
|
||||||
selectedApis = ctx.getKey(
|
selectedApis = ctx.getKey(
|
||||||
SEARCH_PREF_PROVIDERS,
|
"$currentAccount/$SEARCH_PREF_PROVIDERS",
|
||||||
defVal = validAPIs.map { it.name }
|
defVal = validAPIs.map { it.name }
|
||||||
)!!.toMutableSet()
|
)!!.toMutableSet()
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ class SearchFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateList(types: List<TvType>) {
|
fun updateList(types: List<TvType>) {
|
||||||
setKey(SEARCH_PREF_TAGS, types.map { it.name })
|
setKey("$currentAccount/$SEARCH_PREF_TAGS", types.map { it.name })
|
||||||
|
|
||||||
arrayAdapter.clear()
|
arrayAdapter.clear()
|
||||||
currentValidApis = validAPIs.filter { api ->
|
currentValidApis = validAPIs.filter { api ->
|
||||||
|
@ -312,7 +312,7 @@ class SearchFragment : Fragment() {
|
||||||
arrayAdapter.notifyDataSetChanged()
|
arrayAdapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
val selectedSearchTypes = getKey<List<String>>(SEARCH_PREF_TAGS)
|
val selectedSearchTypes = getKey<List<String>>("$currentAccount/$SEARCH_PREF_TAGS")
|
||||||
?.mapNotNull { listName ->
|
?.mapNotNull { listName ->
|
||||||
TvType.values().firstOrNull { it.name == listName }
|
TvType.values().firstOrNull { it.name == listName }
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ class SearchFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.setOnDismissListener {
|
dialog.setOnDismissListener {
|
||||||
context?.setKey(SEARCH_PREF_PROVIDERS, currentSelectedApis.toList())
|
context?.setKey("$currentAccount/$SEARCH_PREF_PROVIDERS", currentSelectedApis.toList())
|
||||||
selectedApis = currentSelectedApis
|
selectedApis = currentSelectedApis
|
||||||
}
|
}
|
||||||
updateList(selectedSearchTypes.toList())
|
updateList(selectedSearchTypes.toList())
|
||||||
|
@ -354,7 +354,7 @@ class SearchFragment : Fragment() {
|
||||||
val settingsManager = context?.let { PreferenceManager.getDefaultSharedPreferences(it) }
|
val settingsManager = context?.let { PreferenceManager.getDefaultSharedPreferences(it) }
|
||||||
val isAdvancedSearch = settingsManager?.getBoolean("advanced_search", true) ?: true
|
val isAdvancedSearch = settingsManager?.getBoolean("advanced_search", true) ?: true
|
||||||
|
|
||||||
selectedSearchTypes = context?.getKey<List<String>>(SEARCH_PREF_TAGS)
|
selectedSearchTypes = context?.getKey<List<String>>("$currentAccount/$SEARCH_PREF_TAGS")
|
||||||
?.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)
|
||||||
|
|
Loading…
Reference in a new issue