Fix Fever adapters not consuming data to the end

This commit is contained in:
Shinokuni 2021-12-27 13:41:01 +01:00
parent 562f11e2cc
commit 0885a9a3e4
6 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package com.readrops.api.services.fever.adapters package com.readrops.api.services.fever.adapters
import com.readrops.api.utils.exceptions.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.extensions.skipField
import com.squareup.moshi.* import com.squareup.moshi.*
class FeverAPIAdapter : JsonAdapter<Boolean>() { class FeverAPIAdapter : JsonAdapter<Boolean>() {
@ -15,16 +16,16 @@ class FeverAPIAdapter : JsonAdapter<Boolean>() {
return try { return try {
beginObject() beginObject()
skipName() skipField()
skipValue()
var authenticated = 0 var authenticated = 0
if (nextName() == "auth") { if (nextName() == "auth") {
authenticated = nextInt() authenticated = nextInt()
} }
skipName() skipField()
skipValue() endObject()
authenticated == 1 authenticated == 1
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -57,6 +57,7 @@ class FeverFaviconsAdapter {
} }
endArray() endArray()
endObject()
favicons favicons
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -54,6 +54,7 @@ class FeverFeedsAdapter {
endArray() endArray()
skipToEnd() skipToEnd()
endObject()
feeds feeds
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -49,6 +49,7 @@ class FeverFoldersAdapter {
endArray() endArray()
skipToEnd() skipToEnd()
endObject()
folders folders
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -57,6 +57,7 @@ class FeverItemsAdapter {
} }
endArray() endArray()
endObject()
items items
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -16,13 +16,12 @@ class FeverItemsIdsAdapter {
@FromJson @FromJson
fun fromJson(reader: JsonReader): List<String> = with(reader) { fun fromJson(reader: JsonReader): List<String> = with(reader) {
return try { return try {
beginObject() beginObject()
repeat(3) { repeat(3) {
skipField() skipField()
} }
nextName() // unread_items_ids field nextName() // (unread|saved)_item_ids field
val ids = nextString().split(",") val ids = nextString().split(",")
endObject() endObject()