From ba8df45bc78c652179a59c5d346435ea39abca72 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 22 Aug 2023 16:32:32 +0200 Subject: [PATCH] avoid falsely shown "Account scheduled for deletion" info ...by setting the correct context. In removeCurrentAccount the WorkManager.getInstance(this) (introduced with commit 943286dd) must be WorkManager.getInstance(applicationContext) because otherwise the worker is dropped when the activity is finished and might not do it's work beforehand (race condition?). This results in users that keep the scheduledForDeletion = true so the next time someone tries to login with this user, userManager.checkIfUserIsScheduledForDeletion(loginData.username!!, baseUrl!!).blockingGet() in WebViewLoginController#parseAndLoginFromWebView is true and ApplicationWideMessageHolder.getInstance().messageType is set to ApplicationWideMessageHolder.MessageType.ACCOUNT_SCHEDULED_FOR_DELETION which results in the "The account is scheduled for deletion, and cannot be changed" message in ServerSelectionController. This is just a guess and i was not able to reproduce it. Signed-off-by: Marcel Hibbe --- .../main/java/com/nextcloud/talk/settings/SettingsActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt index f8c7bb8f2..acf24792b 100644 --- a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt @@ -471,7 +471,7 @@ class SettingsActivity : BaseActivity() { private fun removeCurrentAccount() { val otherUserExists = userManager.scheduleUserForDeletionWithId(currentUser!!.id!!).blockingGet() val accountRemovalWork = OneTimeWorkRequest.Builder(AccountRemovalWorker::class.java).build() - WorkManager.getInstance(this).enqueue(accountRemovalWork) + WorkManager.getInstance(applicationContext).enqueue(accountRemovalWork) if (otherUserExists) { // TODO: find better solution once Conductor is removed finish()