From 1320f9841b4273c755e59e64047203d9b0feed80 Mon Sep 17 00:00:00 2001 From: Tiebe Groosman Date: Mon, 8 May 2023 14:10:56 +0200 Subject: [PATCH] fixes --- buildSrc/src/main/kotlin/Dependencies.kt | 4 +-- .../tiebe/otarium/utils/versions/v21/V21.kt | 35 +++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index a9376bb4..27272263 100755 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,7 +1,7 @@ object Version { - const val appVersion = "3.2.3-alpha" - const val appVersionCode = 31 + const val appVersion = "3.3.0-alpha01" + const val appVersionCode = 32 const val magister = "1.1.8" diff --git a/shared/src/commonMain/kotlin/nl/tiebe/otarium/utils/versions/v21/V21.kt b/shared/src/commonMain/kotlin/nl/tiebe/otarium/utils/versions/v21/V21.kt index bbb3e510..08c459cd 100644 --- a/shared/src/commonMain/kotlin/nl/tiebe/otarium/utils/versions/v21/V21.kt +++ b/shared/src/commonMain/kotlin/nl/tiebe/otarium/utils/versions/v21/V21.kt @@ -14,24 +14,31 @@ import nl.tiebe.otarium.settings fun migrateFromV21() { runBlocking { - val currentAccount: JsonObject = Json.decodeFromString(settings.getStringOrNull("magister_tokens") ?: return@runBlocking) - val accountId = currentAccount["accountId"]!!.jsonPrimitive.content.toInt() - val tokens = Json.decodeFromString(currentAccount["tokens"]!!.jsonObject.toString()) + try { + val currentAccount: JsonObject = + Json.decodeFromString(settings.getStringOrNull("magister_tokens") ?: return@runBlocking) + val accountId = currentAccount["accountId"]!!.jsonPrimitive.content.toInt() + val tokens = Json.decodeFromString(currentAccount["tokens"]!!.jsonObject.toString()) - val profileInfo = ProfileInfoFlow.getProfileInfo(currentAccount["tenantUrl"]!!.jsonPrimitive.content, tokens.accessToken) + val profileInfo = + ProfileInfoFlow.getProfileInfo(currentAccount["tenantUrl"]!!.jsonPrimitive.content, tokens.accessToken) - val newAccount = MagisterAccount(accountId, profileInfo, currentAccount["tenantUrl"]!!.jsonPrimitive.content) + val newAccount = + MagisterAccount(accountId, profileInfo, currentAccount["tenantUrl"]!!.jsonPrimitive.content) - settings.putString("grades-$accountId", settings.getString("grades", "[]")) - settings.putString("full_grade_list-$accountId", settings.getString("full_grade_list", "[]")) - settings.putString("agenda-$accountId", settings.getString("agenda", "[]")) - settings.putString("tokens-${accountId}", Json.encodeToString(tokens)) + settings.putString("grades-$accountId", settings.getString("grades", "[]")) + settings.putString("full_grade_list-$accountId", settings.getString("full_grade_list", "[]")) + settings.putString("agenda-$accountId", settings.getString("agenda", "[]")) + settings.putString("tokens-${accountId}", Json.encodeToString(tokens)) - settings.remove("grades") - settings.remove("full_grade_list") - settings.remove("agenda") - settings.remove("magister_tokens") + settings.remove("grades") + settings.remove("full_grade_list") + settings.remove("agenda") + settings.remove("magister_tokens") - settings.putString("accounts", Json.encodeToString(listOf(newAccount))) + settings.putString("accounts", Json.encodeToString(listOf(newAccount))) + } catch (e: Exception) { + settings.clear() + } } } \ No newline at end of file