feat: removed auto sync
This commit is contained in:
@@ -56,13 +56,21 @@ class ScheduleViewModel(
|
||||
}
|
||||
|
||||
launch {
|
||||
_uiState.value = _uiState.value.copy(isSyncing = true)
|
||||
scheduleRepository.sync(groupId)
|
||||
_uiState.value = _uiState.value.copy(isSyncing = false)
|
||||
syncIfMissingToday(groupId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
viewModelScope.launch {
|
||||
currentGroupId = null
|
||||
|
||||
Reference in New Issue
Block a user