mirror of
https://github.com/pawelorzech/Swoosh.git
synced 2026-03-31 11:55:47 +00:00
fix: prevent "Ghost URL not configured" error after setup
FeedViewModel was created at NavGraph scope, so its init block called refresh() before credentials existed when starting on the setup screen. Guard the init refresh with an isConfigured check and explicitly trigger refresh after setup completes.
This commit is contained in:
parent
74f42fd2f1
commit
beef4c4e1b
2 changed files with 5 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ package com.swoosh.microblog.ui.feed
|
|||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.swoosh.microblog.data.CredentialsManager
|
||||
import com.swoosh.microblog.data.model.*
|
||||
import com.swoosh.microblog.data.repository.PostRepository
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
|
@ -29,7 +30,9 @@ class FeedViewModel(application: Application) : AndroidViewModel(application) {
|
|||
|
||||
init {
|
||||
observeLocalPosts()
|
||||
refresh()
|
||||
if (CredentialsManager(getApplication()).isConfigured) {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeLocalPosts() {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ fun SwooshNavGraph(
|
|||
composable(Routes.SETUP) {
|
||||
SetupScreen(
|
||||
onSetupComplete = {
|
||||
feedViewModel.refresh()
|
||||
navController.navigate(Routes.FEED) {
|
||||
popUpTo(Routes.SETUP) { inclusive = true }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue