Prevent crash when logging in #81
@ -93,6 +93,9 @@ class LoginActivity : AppCompatActivity(), DIAware {
|
||||
}
|
||||
|
||||
private fun goToMain() {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
repository.updateApiVersion()
|
||||
}
|
||||
val intent = Intent(this, HomeActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
|
@ -41,14 +41,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
private var fetchedTags = false
|
||||
|
||||
init {
|
||||
// TODO: Dispatchers.IO not available in KMM, an alternative solution should be found
|
||||
connectivityStatus.start()
|
||||
if (appSettingsService.getBaseUrl() != "") {
|
||||
runBlocking {
|
||||
updateApiVersion()
|
||||
reloadBadges()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AmineB marked this conversation as resolved
Outdated
|
||||
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
|
||||
@ -384,9 +377,6 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
try {
|
||||
val response = api.login()
|
||||
result = response.isSuccess == true
|
||||
if (result) {
|
||||
updateApiVersion()
|
||||
}
|
||||
} catch (cause: Throwable) {
|
||||
Napier.e(cause.stackTraceToString(), tag = "RepositoryImpl.updateRemote")
|
||||
}
|
||||
@ -400,7 +390,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
api.refreshLoginInformation()
|
||||
}
|
||||
|
||||
private suspend fun updateApiVersion() {
|
||||
suspend fun updateApiVersion() {
|
||||
val apiMajorVersion = appSettingsService.getApiVersion()
|
||||
|
||||
if (isNetworkAvailable()) {
|
||||
|
Loading…
Reference in New Issue
Block a user
getBaseUrl
should never return an empty string.There is a verification done before even logging-in (and saving the settings), so this should never happen.
The repository is initialized before logging in, at that point appSettingsService returns an empty string
Ok, so this is a workaround.
The issue is that the
runBlocking
block is called even when the user is'nt updated. This should be fixed.I could remove this from the init method and make a new public method which is called by the login activity after it checks that the user is correctly set.
that could be better, yes !