Skip to content

Commit

Permalink
- Fix: 修正 初始進入 教師行事曆 頁麵時,篩選時間列表為空列表之問題
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei.He committed Jun 8, 2023
1 parent 5d79f81 commit 0653d17
Showing 1 changed file with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ScheduleViewModel @Inject constructor(
private val _scheduleTimeList =
MutableStateFlow<DataSourceResult<MutableList<IntervalScheduleTimeSlot>>>(DataSourceResult.Loading)
private val _queryDateUtc = MutableStateFlow(OffsetDateTime.now())
private val _selectedTab = MutableStateFlow<OffsetDateTime?>(null)
private val _selectedTab = MutableStateFlow(OffsetDateTime.now().getLocalOffsetDateTime())
private var getScheduleJob: Job? = null
private var isUpdatingWeek = false

Expand Down Expand Up @@ -98,27 +98,18 @@ class ScheduleViewModel @Inject constructor(

private fun filterTimeListByDate(
result: DataSourceResult<MutableList<IntervalScheduleTimeSlot>>,
date: OffsetDateTime?
date: OffsetDateTime
) {
when (result) {
is DataSourceResult.Success -> {
if (date != null) {
val filteredList = result.data.filter { item ->
item.start.dayOfYear == date.dayOfYear
}
updateState {
copy(
filteredTimeList = filteredList,
filteredStatus = DataSourceResult.Success(filteredList)
)
}
} else {
updateState {
copy(
filteredTimeList = emptyList(),
filteredStatus = DataSourceResult.Success(emptyList())
)
}
val filteredList = result.data.filter { item ->
item.start.dayOfYear == date.dayOfYear
}
updateState {
copy(
filteredTimeList = filteredList,
filteredStatus = DataSourceResult.Success(filteredList)
)
}
}

Expand Down

0 comments on commit 0653d17

Please sign in to comment.