@@ -83,7 +83,9 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
83
83
import kotlinx.coroutines.Job
84
84
import kotlinx.coroutines.delay
85
85
import kotlinx.coroutines.flow.MutableStateFlow
86
+ import kotlinx.coroutines.flow.combine
86
87
import kotlinx.coroutines.flow.emptyFlow
88
+ import kotlinx.coroutines.flow.filterNotNull
87
89
import kotlinx.coroutines.flow.flatMapLatest
88
90
import kotlinx.coroutines.flow.map
89
91
import kotlinx.coroutines.flow.mapLatest
@@ -156,17 +158,16 @@ class MainViewModel @Inject constructor(
156
158
it?.let (mailboxController::getMailbox)
157
159
}.asLiveData(ioCoroutineContext)
158
160
159
- val currentFoldersLive = _currentMailboxObjectId .flatMapLatest { objectId ->
160
- objectId
161
- ?.let {
162
- folderController.getMenuDrawerFolders().map { (defaultFolders, customFolders) ->
163
- Pair (
164
- defaultFolders.list.flattenFolderChildren(dismissHiddenChildren = true ),
165
- customFolders.list.flattenFolderChildren(dismissHiddenChildren = true ),
166
- )
167
- }
168
- }
169
- ? : emptyFlow()
161
+ private val currentDefaultFoldersLive = _currentMailboxObjectId .filterNotNull().flatMapLatest {
162
+ folderController.getMenuDrawerDefaultFolders().map { it.list.flattenFolderChildren(dismissHiddenChildren = true ) }
163
+ }
164
+
165
+ private val currentCustomFoldersLive = _currentMailboxObjectId .filterNotNull().flatMapLatest {
166
+ folderController.getMenuDrawerCustomFolders().map { it.list.flattenFolderChildren(dismissHiddenChildren = true ) }
167
+ }
168
+
169
+ val currentFoldersLive = currentDefaultFoldersLive.combine(currentCustomFoldersLive) { defaultFolders, customFolders ->
170
+ defaultFolders to customFolders
170
171
}.asLiveData(ioCoroutineContext)
171
172
172
173
val currentQuotasLive = _currentMailboxObjectId .flatMapLatest {
0 commit comments