forked from agzam/vyatsu-schedule
fix(teacher): group day slots by real lesson start time
slotIndex is a per-department index of non-empty intervals, not a time. Merging all departments of a period by slotIndex and deriving the slot time from the first inserted lesson produced shifted times (e.g. Meltsov 10:00 shown at 11:45) depending on sync order. Group by lesson start minute instead so each department's real times are kept. Add debug logging for teacher schedule sync/build and debounce teacher search in picker.
This commit is contained in:
@@ -18,6 +18,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@@ -160,16 +161,18 @@ class PickerViewModel(
|
||||
|
||||
teachersJob?.cancel()
|
||||
teachersJob = viewModelScope.launch {
|
||||
teacherScheduleRepository.observeTeachers(period).collect { teachers ->
|
||||
val query = _uiState.value.teacherQuery
|
||||
val isLoading = _uiState.value.teachersLoading
|
||||
_uiState.value = _uiState.value.copy(
|
||||
teachers = teachers,
|
||||
filteredTeachers = filterTeachers(teachers, query),
|
||||
teachersLoading = isLoading && teachers.isEmpty(),
|
||||
error = null
|
||||
)
|
||||
}
|
||||
teacherScheduleRepository.observeTeachers(period)
|
||||
.debounce(300)
|
||||
.collect { teachers ->
|
||||
val query = _uiState.value.teacherQuery
|
||||
val isLoading = _uiState.value.teachersLoading
|
||||
_uiState.value = _uiState.value.copy(
|
||||
teachers = teachers,
|
||||
filteredTeachers = filterTeachers(teachers, query),
|
||||
teachersLoading = isLoading && teachers.isEmpty(),
|
||||
error = null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user