From ed26cb8f35c9942562541d443abe5b75ee36b552 Mon Sep 17 00:00:00 2001 From: Lokesh Gidra Date: Mon, 13 Nov 2023 17:07:39 +0800 Subject: [PATCH] Move modifyFavorites to use cronet --- .../com/hippo/ehviewer/client/EhEngine.kt | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt b/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt index 043554087..4e1c6b4a7 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt @@ -276,31 +276,21 @@ object EhEngine { GalleryDetailParser.parseComments(document) } - /** - * @param dstCat -1 for delete, 0 - 9 for cloud favorite, others throw Exception - * @param note max 250 characters - */ - suspend fun modifyFavorites( - gid: Long, - token: String?, - dstCat: Int = -1, - note: String = "", - ) { + suspend fun modifyFavorites(gid: Long, token: String?, dstCat: Int = -1, note: String = "") { val catStr: String = when (dstCat) { -1 -> "favdel" in 0..9 -> dstCat.toString() else -> throw EhException("Invalid dstCat: $dstCat") } val url = EhUrl.getAddFavorites(gid, token) - return ehRequest(url, url, EhUrl.origin) { - formBody { - add("favcat", catStr) - add("favnote", note) - // apply=Add+to+Favorites is not necessary, just use apply=Apply+Changes all the time - add("apply", "Apply Changes") - add("update", "1") - } - }.executeAndParsingWith { } + val body = formBody { + add("favcat", catStr) + add("favnote", note) + // apply=Add+to+Favorites is not necessary, just use apply=Apply+Changes all the time + add("apply", "Apply Changes") + add("update", "1") + } + fetchCompat(url, url, EhUrl.origin, body) { } } suspend fun downloadArchive(