Skip to content

Commit

Permalink
[app] filter features
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Nov 2, 2022
1 parent 5062220 commit e4eb305
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ class NavViewModel2 @Inject constructor(@ApplicationContext private val context:
}

fun loadFeatures() {

viewModelScope.launch {
thanox.ifServiceInstalled { thanox ->
val feats = PrebuiltFeatures.all {
it.requiredFeature == null || thanox.hasFeature(it.requiredFeature)
}
_state.value = _state.value.copy(
features = feats
)
}
}
}

fun loadCoreStatus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ object PrebuiltFeatures {
)


fun all(): List<FeatureItemGroup> {
fun all(filter: (FeatureItem) -> Boolean = { true }): List<FeatureItemGroup> {
return listOf(
boost, secure, ext, notification, guide
)
).map {
it.copy(items = it.items.filter(filter))
}
}
}

0 comments on commit e4eb305

Please sign in to comment.