Skip to content

Commit d22a7f0

Browse files
authored
Merge pull request #52 from MMRLApp/copilot/fix-module-listing-issue
Fix module list not populating on initial load
2 parents 83624b0 + 8a2ce05 commit d22a7f0

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

app/src/main/java/com/dergoogler/mmrl/wx/viewmodel/ModulesViewModel.kt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

gradlew

100644100755
File mode changed.

0 commit comments

Comments
 (0)