Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import java.util.concurrent.TimeUnit
*/
class ApiClient(private val session: SessionManager) {

private val json = Json {
/** Lenient decoder shared with callers that unwrap `JsonElement` payloads by hand. */
val json = Json {
ignoreUnknownKeys = true
coerceInputValues = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonPrimitive
import org.cloudreve.android.api.ApiClient
import org.cloudreve.android.api.LoginResponse
Expand Down Expand Up @@ -67,7 +66,7 @@ class LoginViewModel(
?: throw Exception("Server requested 2FA without a session id")
_state.value = _state.value.copy(loading = false, twoFactorSessionId = sessionId, otp = "")
}
0 -> completeLogin(Json.decodeFromJsonElement(LoginResponse.serializer(), body.data))
0 -> completeLogin(api.json.decodeFromJsonElement(LoginResponse.serializer(), body.data))
else -> throw Exception(body.msg.ifBlank { "Login failed" })
}
} catch (e: Exception) {
Expand Down