Auto commit Tue Mar 24 07:01:02 PM CDT 2026

This commit is contained in:
Tretzi
2026-03-24 19:01:02 -05:00
parent 1d4a599dd6
commit 11445d10dd
2 changed files with 94 additions and 46 deletions

View File

@@ -142,25 +142,13 @@ class MainViewModel(
fun acknowledgeSafety() = viewModelScope.launch { settingsRepository.acknowledgeSafety(SAFETY_VERSION) }
fun choosePreset(id: String) = viewModelScope.launch {
val state = _ui.value
val preset = state.presets.first { it.id == id }
settingsRepository.updateLastPreset(id)
_ui.update {
val cfg = preset.toConfig(SessionMode.AUDIO_VISUAL)
val timeline = timelineForProgramId(preset.id, cachedPrograms)
val savedSignature = timelineProgramSignature(timeline)
it.copy(
selectedPreset = preset,
config = cfg.copy(durationSec = cfg.durationSec.coerceIn(60, 8 * 60 * 60)),
timeline = timeline,
savedProgramName = preset.name,
savedTimelineSignature = savedSignature,
hasUnsavedChanges = false,
error = null,
)
}
elapsedBeforePauseSec = 0f
fun choosePreset(id: String) {
applyPresetSelection(id)
}
fun startSessionFromProgramSelection(id: String): Boolean {
applyPresetSelection(id)
return startSession()
}
fun createNewProgramDraft() {
@@ -442,6 +430,31 @@ class MainViewModel(
return settings.forceAudioWithoutHeadphones || headsetAvailable
}
private fun applyPresetSelection(id: String) {
val state = _ui.value
val preset = state.presets.firstOrNull { it.id == id } ?: return
_ui.update {
val cfg = preset.toConfig(SessionMode.AUDIO_VISUAL)
val timeline = timelineForProgramId(preset.id, cachedPrograms)
val savedSignature = timelineProgramSignature(timeline)
it.copy(
selectedPreset = preset,
config = cfg.copy(durationSec = cfg.durationSec.coerceIn(60, 8 * 60 * 60)),
timeline = timeline,
savedProgramName = preset.name,
savedTimelineSignature = savedSignature,
hasUnsavedChanges = false,
error = null,
)
}
elapsedBeforePauseSec = 0f
viewModelScope.launch {
settingsRepository.updateLastPreset(id)
}
}
private fun currentElapsedSec(): Float {
val state = _ui.value
val total = state.timeline.durationSec.toFloat().coerceAtLeast(1f)