From 0653d176271f5cd7880632d8a033868032e6ae9d Mon Sep 17 00:00:00 2001 From: "Wei.He" Date: Thu, 8 Jun 2023 17:25:47 +0800 Subject: [PATCH] =?UTF-8?q?-=20Fix:=20=E4=BF=AE=E6=AD=A3=20=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E9=80=B2=E5=85=A5=20=E6=95=99=E5=B8=AB=E8=A1=8C?= =?UTF-8?q?=E4=BA=8B=E6=9B=86=20=E9=A0=81=E9=BA=B5=E6=99=82=EF=BC=8C?= =?UTF-8?q?=E7=AF=A9=E9=81=B8=E6=99=82=E9=96=93=E5=88=97=E8=A1=A8=E7=82=BA?= =?UTF-8?q?=E7=A9=BA=E5=88=97=E8=A1=A8=E4=B9=8B=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../viewmodels/ScheduleViewModel.kt | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/feature/teacherschedule/src/main/java/com/wei/amazingtalker_recruit/feature/teacherschedule/viewmodels/ScheduleViewModel.kt b/feature/teacherschedule/src/main/java/com/wei/amazingtalker_recruit/feature/teacherschedule/viewmodels/ScheduleViewModel.kt index dd3b94c8..20398a05 100644 --- a/feature/teacherschedule/src/main/java/com/wei/amazingtalker_recruit/feature/teacherschedule/viewmodels/ScheduleViewModel.kt +++ b/feature/teacherschedule/src/main/java/com/wei/amazingtalker_recruit/feature/teacherschedule/viewmodels/ScheduleViewModel.kt @@ -39,7 +39,7 @@ class ScheduleViewModel @Inject constructor( private val _scheduleTimeList = MutableStateFlow>>(DataSourceResult.Loading) private val _queryDateUtc = MutableStateFlow(OffsetDateTime.now()) - private val _selectedTab = MutableStateFlow(null) + private val _selectedTab = MutableStateFlow(OffsetDateTime.now().getLocalOffsetDateTime()) private var getScheduleJob: Job? = null private var isUpdatingWeek = false @@ -98,27 +98,18 @@ class ScheduleViewModel @Inject constructor( private fun filterTimeListByDate( result: DataSourceResult>, - 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) + ) } }