Skip to content

Commit

Permalink
add a config parameter for the number of favorites tools available on…
Browse files Browse the repository at this point in the history
… the home screen
  • Loading branch information
frett committed Jan 13, 2025
1 parent 9135651 commit 4d4359c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/google-services.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"project_number": "71275134527",
"firebase_url": "https://godtools-b2f82.firebaseio.com",
"project_id": "godtools-b2f82",
"storage_bucket": "godtools-b2f82.appspot.com"
"storage_bucket": "godtools-b2f82.firebasestorage.app"
},
"client": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.slack.circuit.codegen.annotations.CircuitInject
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.presenter.Presenter
Expand All @@ -23,6 +24,7 @@ import org.cru.godtools.analytics.model.OpenAnalyticsActionEvent.Companion.ACTIO
import org.cru.godtools.analytics.model.OpenAnalyticsActionEvent.Companion.ACTION_OPEN_TOOL_DETAILS
import org.cru.godtools.analytics.model.OpenAnalyticsActionEvent.Companion.SOURCE_FAVORITE
import org.cru.godtools.analytics.model.OpenAnalyticsActionEvent.Companion.SOURCE_FEATURED
import org.cru.godtools.base.CONFIG_UI_DASHBOARD_HOME_FAVORITE_TOOLS
import org.cru.godtools.base.Settings
import org.cru.godtools.db.repository.ToolsRepository
import org.cru.godtools.tutorial.PageSet
Expand All @@ -40,6 +42,7 @@ class HomePresenter @AssistedInject constructor(
@ApplicationContext
private val context: Context,
private val eventBus: EventBus,
private val remoteConfig: FirebaseRemoteConfig,
private val settings: Settings,
private val toolCardPresenter: ToolCardPresenter,
private val toolsRepository: ToolsRepository,
Expand Down Expand Up @@ -107,8 +110,15 @@ class HomePresenter @AssistedInject constructor(
}

@Composable
private fun rememberFavoriteTools() = remember { toolsRepository.getFavoriteToolsFlow().map { it.take(5) } }
.collectAsState(null).value
private fun rememberFavoriteTools() = remember {
toolsRepository.getFavoriteToolsFlow()
.map {
it.take(
remoteConfig.getLong(CONFIG_UI_DASHBOARD_HOME_FAVORITE_TOOLS)
.coerceIn(0, Int.MAX_VALUE.toLong()).toInt()
)
}
}.collectAsState(null).value
?.mapNotNull { tool ->
val toolCode = tool.code ?: return@mapNotNull null

Expand Down
2 changes: 2 additions & 0 deletions library/base/src/main/kotlin/org/cru/godtools/base/Config.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.cru.godtools.base

const val CONFIG_UI_DASHBOARD_HOME_FAVORITE_TOOLS = "ui_dashboard_home_favorite_tool_cards_count"
const val CONFIG_UI_GLOBAL_ACTIVITY_ENABLED = "ui_account_globalactivity_enabled"

internal val CONFIG_DEFAULTS = mapOf(
CONFIG_UI_DASHBOARD_HOME_FAVORITE_TOOLS to 5,
CONFIG_UI_GLOBAL_ACTIVITY_ENABLED to true
)

0 comments on commit 4d4359c

Please sign in to comment.