Skip to content

Commit

Permalink
Merge pull request #82 from Taewan-P/fix/setting-not-saved
Browse files Browse the repository at this point in the history
Fix going to intro screen when Ollama is only initially selected and used
  • Loading branch information
Taewan-P authored Oct 26, 2024
2 parents 437f033 + ff590a6 commit 0abb6d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MainViewModel @Inject constructor(private val settingRepository: SettingRe
viewModelScope.launch {
val platforms = settingRepository.fetchPlatforms()

if (platforms.all { it.token == null || it.model == null }) {
if (platforms.all { it.enabled.not() }) {
// Initialize
sendSplashEvent(SplashEvent.OpenIntro)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class SetupViewModel @Inject constructor(private val settingRepository: SettingR
Route.OLLAMA_API_ADDRESS,
Route.SETUP_COMPLETE
)
val commonSteps = setOf(Route.SELECT_PLATFORM, Route.TOKEN_INPUT, Route.SETUP_COMPLETE)
val commonSteps = mutableSetOf(Route.SELECT_PLATFORM, Route.TOKEN_INPUT, Route.SETUP_COMPLETE)
val platformStep = mapOf(
Route.OPENAI_MODEL_SELECT to ApiType.OPENAI,
Route.ANTHROPIC_MODEL_SELECT to ApiType.ANTHROPIC,
Expand All @@ -129,6 +129,12 @@ class SetupViewModel @Inject constructor(private val settingRepository: SettingR

val currentIndex = steps.indexOfFirst { it == currentRoute }
val enabledPlatform = platformState.value.filter { it.selected }.map { it.name }.toSet()

if (enabledPlatform.size == 1 && ApiType.OLLAMA in enabledPlatform) {
// Skip API Token input page
commonSteps.remove(Route.TOKEN_INPUT)
}

val remainingSteps = steps.filterIndexed { index, setupStep ->
index > currentIndex &&
(setupStep in commonSteps || platformStep[setupStep] in enabledPlatform)
Expand Down

0 comments on commit 0abb6d0

Please sign in to comment.