Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/java/org/wikipedia/csrf/CsrfTokenClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.wikipedia.csrf
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.schedulers.Schedulers
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
Expand Down Expand Up @@ -36,6 +37,8 @@ object CsrfTokenClient {
// Log in explicitly
try {
LoginClient().loginBlocking(site, AccountUtil.userName, AccountUtil.password!!, "")
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
L.e(e)
lastError = e
Expand All @@ -51,6 +54,8 @@ object CsrfTokenClient {
if (AccountUtil.isLoggedIn && token == ANON_TOKEN) {
throw RuntimeException("App believes we're logged in, but got anonymous token.")
}
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
L.e(e)
lastError = e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class DescriptionEditViewModel(bundle: Bundle) : ViewModel() {
if (shouldWriteToLocalWiki()) pageTitle.wikiSite else Constants.wikidataWikiSite
}

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

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