Skip to content

Commit

Permalink
fix: global rule should not be show when turn off (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Jul 20, 2024
1 parent 3766c35 commit dc26d96
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions app/src/main/kotlin/li/songe/gkd/ui/AppConfigVm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,19 @@ class AppConfigVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel
DbSet.subsConfigDao.queryGlobalConfig(subs.map { it.first.id })
}.flatMapLatest { it }
val globalGroupsFlow = combine(sortedGlobalGroupsFlow, globalConfigs) { groups, configs ->
groups.map { g ->
ResolvedGlobalGroup(
group = g.group,
subsItem = g.subsItem,
subscription = g.subscription,
config = configs.find { c -> c.subsItemId == g.subsItem.id && c.groupKey == g.group.key },
)
groups.mapNotNull { g ->
val config =
configs.find { c -> c.subsItemId == g.subsItem.id && c.groupKey == g.group.key }
if (config?.enable == false) {
null
} else {
ResolvedGlobalGroup(
group = g.group,
subsItem = g.subsItem,
subscription = g.subscription,
config = config,
)
}
}
}.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())

Expand Down

0 comments on commit dc26d96

Please sign in to comment.