@@ -83,22 +83,24 @@ class ModulesViewModel @Inject constructor(
8383 private fun dataObserver () {
8484 getLocalAllAsFlow()
8585 .combine(modulesMenu) { list, menu ->
86- if (list.isEmpty()) return @combine
87-
88- cacheFlow.value = list.sortedWith(
89- comparator(menu.option, menu.descending)
90- ).let { v ->
91- val a = if (menu.pinEnabled) {
92- v.sortedByDescending { it.state == State .ENABLE }
93- } else v
94-
95- val b = if (menu.pinAction) {
96- a.sortedByDescending { it.hasAction }
97- } else a
98-
99- if (menu.pinWebUI) {
100- b.sortedByDescending { it.hasWebUI }
101- } else b
86+ cacheFlow.value = if (list.isEmpty()) {
87+ emptyList()
88+ } else {
89+ list.sortedWith(
90+ comparator(menu.option, menu.descending)
91+ ).let { v ->
92+ val a = if (menu.pinEnabled) {
93+ v.sortedByDescending { it.state == State .ENABLE }
94+ } else v
95+
96+ val b = if (menu.pinAction) {
97+ a.sortedByDescending { it.hasAction }
98+ } else a
99+
100+ if (menu.pinWebUI) {
101+ b.sortedByDescending { it.hasWebUI }
102+ } else b
103+ }
102104 }
103105
104106 isLoadingFlow.update { false }
@@ -230,7 +232,7 @@ class ModulesViewModel @Inject constructor(
230232 }
231233 .stateIn(
232234 scope = viewModelScope,
233- started = SharingStarted .WhileSubscribed ( 5000 ) ,
235+ started = SharingStarted .Eagerly ,
234236 initialValue = ModulesScreenState ()
235237 )
236238
0 commit comments