Rework repository initialization
This commit is contained in:
parent
c25e8889a4
commit
53b1d1f8b2
@ -93,6 +93,9 @@ class LoginActivity : AppCompatActivity(), DIAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun goToMain() {
|
private fun goToMain() {
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
repository.updateApiVersion()
|
||||||
|
}
|
||||||
val intent = Intent(this, HomeActivity::class.java)
|
val intent = Intent(this, HomeActivity::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
finish()
|
finish()
|
||||||
|
@ -41,14 +41,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
private var fetchedTags = false
|
private var fetchedTags = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// TODO: Dispatchers.IO not available in KMM, an alternative solution should be found
|
|
||||||
connectivityStatus.start()
|
connectivityStatus.start()
|
||||||
if (appSettingsService.getBaseUrl() != "") {
|
|
||||||
runBlocking {
|
|
||||||
updateApiVersion()
|
|
||||||
reloadBadges()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
|
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
|
||||||
@ -384,9 +377,6 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
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")
|
||||||
}
|
}
|
||||||
@ -400,7 +390,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
api.refreshLoginInformation()
|
api.refreshLoginInformation()
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun updateApiVersion() {
|
suspend fun updateApiVersion() {
|
||||||
val apiMajorVersion = appSettingsService.getApiVersion()
|
val apiMajorVersion = appSettingsService.getApiVersion()
|
||||||
|
|
||||||
if (isNetworkAvailable()) {
|
if (isNetworkAvailable()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user