From 3e18231eea47178950e876aa6cdf569d585e78ec Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Fri, 15 Dec 2023 22:20:51 +0100 Subject: [PATCH 1/5] Bump lemmyapi --- app/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 10fea8e4e..597dfb2d9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -187,7 +187,7 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.6") - implementation("it.vercruysse.lemmyapi:lemmy-api-jvm:0.1.0-SNAPSHOT") + implementation("it.vercruysse.lemmyapi:lemmy-api:0.2.0-SNAPSHOT") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.1") // Ktor uses SLF4J implementation("org.slf4j:slf4j-api:2.0.9") From f8661cf2af8f3a6aea0a9dfeb269235770d3bd6e Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Fri, 15 Dec 2023 22:40:34 +0100 Subject: [PATCH 2/5] Fix weird edgecase account not being deleted --- .../com/jerboa/feat/AccountVerificationState.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt b/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt index 9e0c7fa5c..7608316bd 100644 --- a/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt +++ b/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt @@ -157,7 +157,7 @@ suspend fun checkIfJWTValid(api: LemmyApi): CheckState { val resp = api.validateAuth() return@withContext if (resp.isSuccess) { - CheckState.Passed + CheckState.Failed // Could check for exact body response `{"error":"not_logged_in"}` but could change over time and is unneeded } else if ((resp.exceptionOrNull() as? LemmyBadRequestException)?.code in 400..499) { CheckState.Failed @@ -421,13 +421,16 @@ suspend fun Account.isReadyAndIfNotDisplayInfo( } AccountVerificationState.ACCOUNT_DELETED to CheckState.Failed -> { - accountVM.deleteAccountAndSwapCurrent(this, swapToAnon = true) - appState.toHome() + accountVM.deleteAccountAndSwapCurrent(this, swapToAnon = true).invokeOnCompletion { + appState.toLogin() + } } AccountVerificationState.JWT_VERIFIED to CheckState.Failed -> { - accountVM.deleteAccountAndSwapCurrent(this, swapToAnon = true) - appState.toLogin() + accountVM.deleteAccountAndSwapCurrent(this, swapToAnon = true).invokeOnCompletion { + appState.toLogin() + } + } else -> From db4798bb01bed8db1b45727f6b05c5cefba2e6e8 Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Fri, 15 Dec 2023 22:45:50 +0100 Subject: [PATCH 3/5] Undo testing --- app/src/main/java/com/jerboa/feat/AccountVerificationState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt b/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt index 7608316bd..78f15b25d 100644 --- a/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt +++ b/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt @@ -157,7 +157,7 @@ suspend fun checkIfJWTValid(api: LemmyApi): CheckState { val resp = api.validateAuth() return@withContext if (resp.isSuccess) { - CheckState.Failed + CheckState.Passed // Could check for exact body response `{"error":"not_logged_in"}` but could change over time and is unneeded } else if ((resp.exceptionOrNull() as? LemmyBadRequestException)?.code in 400..499) { CheckState.Failed From 092415e261581be18e01b04c20e71cfe16197260 Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Fri, 15 Dec 2023 22:46:16 +0100 Subject: [PATCH 4/5] Remove remnant --- app/src/main/java/com/jerboa/db/entity/Account.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/com/jerboa/db/entity/Account.kt b/app/src/main/java/com/jerboa/db/entity/Account.kt index 2592d3050..f09771b66 100644 --- a/app/src/main/java/com/jerboa/db/entity/Account.kt +++ b/app/src/main/java/com/jerboa/db/entity/Account.kt @@ -49,6 +49,3 @@ fun Account.isReady(): Boolean { return this.verificationState == AccountVerificationState.CHECKS_COMPLETE.ordinal } -fun Account.getJWT(): String? { - return if (isAnon()) null else this.jwt -} From daaf1dc7387b2c2b9decd19bbd7d18fe2ee1652f Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Fri, 15 Dec 2023 22:56:49 +0100 Subject: [PATCH 5/5] Fix lint --- app/src/main/java/com/jerboa/db/entity/Account.kt | 1 - app/src/main/java/com/jerboa/feat/AccountVerificationState.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/app/src/main/java/com/jerboa/db/entity/Account.kt b/app/src/main/java/com/jerboa/db/entity/Account.kt index f09771b66..4205d168a 100644 --- a/app/src/main/java/com/jerboa/db/entity/Account.kt +++ b/app/src/main/java/com/jerboa/db/entity/Account.kt @@ -48,4 +48,3 @@ fun Account.isAnon(): Boolean { fun Account.isReady(): Boolean { return this.verificationState == AccountVerificationState.CHECKS_COMPLETE.ordinal } - diff --git a/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt b/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt index 78f15b25d..323c30a6b 100644 --- a/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt +++ b/app/src/main/java/com/jerboa/feat/AccountVerificationState.kt @@ -430,7 +430,6 @@ suspend fun Account.isReadyAndIfNotDisplayInfo( accountVM.deleteAccountAndSwapCurrent(this, swapToAnon = true).invokeOnCompletion { appState.toLogin() } - } else ->