Compare commits

...

2 Commits

Author SHA1 Message Date
Amine Louveau
fbcb428e96 Merge pull request 'Fetch api version on login' (#39) from davidoskky/ReaderForSelfoss-multiplatform:loginApi into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://gitea.amine-louveau.fr/Louvorg/ReaderForSelfoss-multiplatform/pulls/39
2022-08-25 02:25:27 +00:00
e281751bb0 Fetch api version on login
All checks were successful
continuous-integration/drone/pr Build is passing
2022-08-24 23:26:49 +02:00

View File

@ -44,7 +44,6 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
// TODO: Dispatchers.IO not available in KMM, an alternative solution should be found // TODO: Dispatchers.IO not available in KMM, an alternative solution should be found
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {
updateApiVersion() updateApiVersion()
dateUtils = DateUtils(apiMajorVersion)
reloadBadges() reloadBadges()
} }
} }
@ -343,6 +342,9 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
try { try {
val response = api.login() val response = api.login()
result = response?.isSuccess == true result = response?.isSuccess == true
if (result) {
updateApiVersion()
}
} catch (cause: Throwable) { } catch (cause: Throwable) {
Napier.e(cause.stackTraceToString(), tag = "RepositoryImpl.updateRemote") Napier.e(cause.stackTraceToString(), tag = "RepositoryImpl.updateRemote")
} }
@ -373,6 +375,7 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
settings.putInt("apiVersionMajor", apiMajorVersion) settings.putInt("apiVersionMajor", apiMajorVersion)
} }
} }
dateUtils = DateUtils(apiMajorVersion)
} }
fun isNetworkAvailable() = isConnectionAvailable.value && !offlineOverride fun isNetworkAvailable() = isConnectionAvailable.value && !offlineOverride