feat: removed auto sync
This commit is contained in:
@@ -56,13 +56,21 @@ class ScheduleViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
launch {
|
launch {
|
||||||
_uiState.value = _uiState.value.copy(isSyncing = true)
|
syncIfMissingToday(groupId)
|
||||||
scheduleRepository.sync(groupId)
|
|
||||||
_uiState.value = _uiState.value.copy(isSyncing = false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun syncIfMissingToday(groupId: String) {
|
||||||
|
val schedule = scheduleRepository.getSchedule(groupId)
|
||||||
|
val today = ScheduleDates.moscowToday()
|
||||||
|
val hasTodayPeriod = schedule?.periodOf(today) != null
|
||||||
|
if (hasTodayPeriod) return
|
||||||
|
_uiState.value = _uiState.value.copy(isSyncing = true)
|
||||||
|
scheduleRepository.sync(groupId)
|
||||||
|
_uiState.value = _uiState.value.copy(isSyncing = false)
|
||||||
|
}
|
||||||
|
|
||||||
fun switchGroup() {
|
fun switchGroup() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
currentGroupId = null
|
currentGroupId = null
|
||||||
|
|||||||
Reference in New Issue
Block a user