Skip to content

Commit 4041d4c

Browse files
authored
Follow-up to Csrf coroutine refactor. (#4991)
1 parent c8635e0 commit 4041d4c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/src/main/java/org/wikipedia/csrf/CsrfTokenClient.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.wikipedia.csrf
33
import io.reactivex.rxjava3.core.Completable
44
import io.reactivex.rxjava3.core.Observable
55
import io.reactivex.rxjava3.schedulers.Schedulers
6+
import kotlinx.coroutines.CancellationException
67
import kotlinx.coroutines.Dispatchers
78
import kotlinx.coroutines.runBlocking
89
import kotlinx.coroutines.withContext
@@ -36,6 +37,8 @@ object CsrfTokenClient {
3637
// Log in explicitly
3738
try {
3839
LoginClient().loginBlocking(site, AccountUtil.userName, AccountUtil.password!!, "")
40+
} catch (e: CancellationException) {
41+
throw e
3942
} catch (e: Exception) {
4043
L.e(e)
4144
lastError = e
@@ -51,6 +54,8 @@ object CsrfTokenClient {
5154
if (AccountUtil.isLoggedIn && token == ANON_TOKEN) {
5255
throw RuntimeException("App believes we're logged in, but got anonymous token.")
5356
}
57+
} catch (e: CancellationException) {
58+
throw e
5459
} catch (e: Exception) {
5560
L.e(e)
5661
lastError = e

app/src/main/java/org/wikipedia/descriptions/DescriptionEditViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DescriptionEditViewModel(bundle: Bundle) : ViewModel() {
124124
if (shouldWriteToLocalWiki()) pageTitle.wikiSite else Constants.wikidataWikiSite
125125
}
126126

127-
val csrfToken = withContext(Dispatchers.IO) { CsrfTokenClient.getToken(csrfSite).blockingSingle() }
127+
val csrfToken = CsrfTokenClient.getTokenBlocking(csrfSite)
128128

129129
val response = if (shouldWriteToLocalWiki()) {
130130
// If the description is being applied to an article on English Wikipedia, it

0 commit comments

Comments
 (0)