[Kavita] Patch - Fix for null cast exception (#19382)

* Fixed missing check if smart-filter is not loaded (due to not being any in kavita instance)
Handled fetch errors more broadly

* Bump version
This commit is contained in:
ThePromidius 2023-12-22 18:31:19 +01:00 committed by GitHub
parent b5f67c3778
commit 0530949ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 12 deletions

View File

@ -1,12 +1,19 @@
## 1.3.13
### Fixed
* Fixed 'null cannot be cast to non-null type' exception
## 1.3.12
## Features
### Features
* Migrate filters to v2
* Implemented smartFilters
* Added localization support
## Fixed
### Fixed
* Fixed publication status not showing
## 1.3.10

View File

@ -6,7 +6,7 @@ ext {
extName = 'Kavita'
pkgNameSuffix = 'all.kavita'
extClass = '.KavitaFactory'
extVersionCode = 12
extVersionCode = 13
}
dependencies {

View File

@ -125,12 +125,17 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
// Get Http code
val field = throwable.javaClass.getDeclaredField("code")
field.isAccessible = true // Make the field accessible
var code = field.get(throwable) // Get the value of the code property
Log.e(LOG_TAG, "Error fetching manga: ${throwable.message}", throwable)
if (code as Int !in intArrayOf(401, 201, 500)) {
code = 500
try {
var code = field.get(throwable) // Get the value of the code property
Log.e(LOG_TAG, "Error fetching manga: ${throwable.message}", throwable)
if (code as Int !in intArrayOf(401, 201, 500)) {
code = 500
}
return@onErrorResumeNext Observable.error(IOException("Http Error: $code\n ${helper.intl["http_errors_$code"]}\n${helper.intl["check_version"]}"))
} catch (e: Exception) {
Log.e(LOG_TAG, e.toString(), e)
return@onErrorResumeNext Observable.error(e)
}
return@onErrorResumeNext Observable.error(IOException("Http Error: $code\n ${helper.intl["http_errors_$code"]}\n${helper.intl["check_version"]}"))
}
.map { response ->
popularMangaParse(response)
@ -188,10 +193,15 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val newFilter = MetadataPayload() // need to reset it or will double
val smartFilterFilter = filters.find { it is SmartFiltersFilter }
// If a SmartFilter selected, apply its filter and return that
if (smartFilterFilter?.state != 0) {
val index = smartFilterFilter?.state as Int - 1
if (smartFilterFilter?.state != 0 && smartFilterFilter != null) {
val index = try {
smartFilterFilter?.state as Int - 1
} catch (e: Exception) {
Log.e(LOG_TAG, e.toString(), e)
0
}
val filter: SmartFilter = smartFilters[index]
val payload = buildJsonObject {
put("EncodedFilter", filter.filter)

View File

@ -11,7 +11,7 @@ object KavitaInt {
SPANISH,
SPANISH_LATAM,
NORWEGIAN,
FRENCH
FRENCH,
)
const val KAVITA_NAME = "Kavita"
}