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 <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-08-22 16:32:32 +02:00
parent 2260f2816b
commit ba8df45bc7
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -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()