fix: notification choosing wrong source

This commit is contained in:
rebelonion 2024-04-29 17:51:41 -05:00
parent e9a60eafb6
commit eca38070cb

View file

@ -23,7 +23,7 @@ class SubscriptionHelper {
mediaId: Int
): Selected {
val data =
PrefManager.getNullableCustomVal("${mediaId}-select", null, Selected::class.java)
PrefManager.getNullableCustomVal("Selected-${mediaId}", null, Selected::class.java)
?: Selected().let {
it.sourceIndex = 0
it.preferDub = PrefManager.getVal(PrefName.SettingsPreferDub)
@ -33,13 +33,16 @@ class SubscriptionHelper {
}
private fun saveSelected(mediaId: Int, data: Selected) {
PrefManager.setCustomVal("${mediaId}-select", data)
PrefManager.setCustomVal("Selected-${mediaId}", data)
}
fun getAnimeParser(id: Int): AnimeParser {
val sources = AnimeSources
Logger.log("getAnimeParser size: ${sources.list.size}")
val selected = loadSelected(id)
if (selected.sourceIndex >= sources.list.size) {
selected.sourceIndex = 0
}
val parser = sources[selected.sourceIndex]
parser.selectDub = selected.preferDub
return parser
@ -76,7 +79,11 @@ class SubscriptionHelper {
fun getMangaParser(id: Int): MangaParser {
val sources = MangaSources
Logger.log("getMangaParser size: ${sources.list.size}")
val selected = loadSelected(id)
if (selected.sourceIndex >= sources.list.size) {
selected.sourceIndex = 0
}
return sources[selected.sourceIndex]
}