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