forked from agzam/vyatsu-schedule
refactor: database multi-period schedule storage
This commit is contained in:
@@ -93,6 +93,23 @@ class ScheduleViewModel(
|
||||
_uiState.value = _uiState.value.copy(selectedIndex = index)
|
||||
}
|
||||
|
||||
fun clearAll() {
|
||||
val groupId = currentGroupId ?: return
|
||||
viewModelScope.launch {
|
||||
scheduleRepository.clearAll(groupId)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearSelectedPeriod() {
|
||||
val state = _uiState.value
|
||||
val schedule = state.schedule ?: return
|
||||
val day = schedule.days.getOrNull(state.selectedIndex) ?: return
|
||||
val period = schedule.periodOf(day.date) ?: return
|
||||
viewModelScope.launch {
|
||||
scheduleRepository.clearPeriod(schedule.groupId, period)
|
||||
}
|
||||
}
|
||||
|
||||
private fun todayIndex(days: List<Day>): Int {
|
||||
if (days.isEmpty()) return 0
|
||||
val today = ScheduleDates.moscowToday()
|
||||
|
||||
Reference in New Issue
Block a user