refactor: replace PendingActionCard.action lambda with HomeActionTarget (batch v1.0.13)

- PendingActionCard now uses target enum instead of lambda
- HomeScreen routes pending actions through toActionHandler
- Remove onPendingAction callback, simplify HomeCallbacks
- Fix WeeklyRecapGenerator filter logic (remove always-true || true)
This commit is contained in:
null 2026-06-19 23:51:47 -05:00
parent 0e75b3b536
commit 195dfb5a0a
3 changed files with 19 additions and 32 deletions

View File

@ -119,7 +119,7 @@ object WeeklyRecapGenerator {
val byFavorite = favoriteCategory?.let { cat ->
availablePacks
.filter { cat in it.categoryIds && it.categoryIds.any { id -> id !in usedCategoryIds || true } }
.filter { cat in it.categoryIds && it.categoryIds.any { id -> id !in usedCategoryIds } }
.maxByOrNull { it.categoryIds.count { id -> id == cat } }
}

View File

@ -108,17 +108,6 @@ fun HomeScreen(
onInvite = { onNavigate(AppRoute.CREATE_INVITE) },
onReminder = viewModel::sendGentleReminder,
onReveal = { state.dailyQuestion?.id?.let { onNavigate(AppRoute.answerReveal(it)) } },
onPendingAction = { card ->
when (card.priority) {
1 -> state.dailyQuestion?.id?.let { onNavigate(AppRoute.answerReveal(it)) }
2 -> onNavigate(AppRoute.DAILY_QUESTION)
3 -> onNavigate(AppRoute.PLAY)
4 -> onNavigate(AppRoute.CONNECTION_CHALLENGES)
5 -> onNavigate(AppRoute.DATE_MATCHES)
6 -> onNavigate(AppRoute.MEMORY_LANE)
else -> {}
}
},
onFollowUp = { state.dailyQuestion?.let { onNavigate(AppRoute.questionThread(state.coupleId ?: "", it.id)) } },
onRefresh = viewModel::loadHome
)
@ -129,7 +118,6 @@ data class HomeCallbacks(
val onReminder: () -> Unit,
val onReveal: () -> Unit,
val onFollowUp: () -> Unit,
val onPendingAction: (PendingActionCard) -> Unit,
val onPacks: () -> Unit,
val onCategory: (String) -> Unit,
val onHistory: () -> Unit,
@ -167,11 +155,10 @@ private fun HomeContent(
onReminder: () -> Unit,
onReveal: () -> Unit,
onFollowUp: () -> Unit,
onPendingAction: (PendingActionCard) -> Unit,
onRefresh: () -> Unit
) {
val callbacks = remember(
onDailyQuestion, onReminder, onReveal, onFollowUp, onPendingAction,
onDailyQuestion, onReminder, onReveal, onFollowUp,
onPacks, onCategory, onHistory, onSettings, onInvite, onRefresh
) {
HomeCallbacks(
@ -179,7 +166,6 @@ private fun HomeContent(
onReminder = onReminder,
onReveal = onReveal,
onFollowUp = onFollowUp,
onPendingAction = onPendingAction,
onPacks = onPacks,
onCategory = onCategory,
onHistory = onHistory,
@ -190,8 +176,16 @@ private fun HomeContent(
}
val onActionSelected = callbacks.toActionHandler(onNavigate)
val onPendingActionSelected: (PendingActionCard) -> Unit = { card ->
card.action()
callbacks.onPendingAction(card)
onActionSelected(
HomeAction(
eyebrow = "",
title = "",
body = "",
cta = "",
target = card.target,
tone = HomeActionTone.Daily
)
)
}
Box(
modifier = Modifier
@ -967,7 +961,6 @@ fun HomeScreenPreview() {
onHistory = {},
onSettings = {},
onInvite = {},
onPendingAction = {},
onRefresh = {}
)
}

View File

@ -88,7 +88,7 @@ data class PendingActionCard(
val title: String,
val subtitle: String?,
val priority: Int,
val action: () -> Unit
val target: HomeActionTarget
)
enum class DailyQuestionState {
@ -581,63 +581,57 @@ class HomeViewModel @Inject constructor(
val actions = mutableListOf<PendingActionCard>()
// 1. Reveal ready (highest priority)
if (dailyQuestionState == DailyQuestionState.BOTH_ANSWERED) {
actions += PendingActionCard(
title = "Reveal is ready",
subtitle = "Both of you answered tonight. Open it together.",
priority = 1,
action = {}
target = HomeActionTarget.AnswerReveal
)
}
// 2. Partner answered, waiting for user
if (dailyQuestionState == DailyQuestionState.PARTNER_ANSWERED_USER_PENDING) {
actions += PendingActionCard(
title = "Your partner answered",
subtitle = "Answer tonights question to unlock the reveal.",
priority = 2,
action = {}
target = HomeActionTarget.DailyQuestion
)
}
// 3. Game waiting (placeholder until QuestionSessionRepository is wired)
if (hasWaitingGame()) {
actions += PendingActionCard(
title = "Game waiting",
subtitle = "Your turn to play a game together.",
priority = 3,
action = {}
target = HomeActionTarget.Game
)
}
// 4. Challenge incomplete (placeholder until challenge data is wired)
if (hasIncompleteChallenge()) {
actions += PendingActionCard(
title = "Challenge waiting",
subtitle = "Todays small step is ready for both of you.",
priority = 4,
action = {}
target = HomeActionTarget.Challenge
)
}
// 5. Date reminder (placeholder until DatePlanRepository is wired)
if (hasUpcomingDate()) {
actions += PendingActionCard(
title = "Date coming up",
subtitle = "A planned moment is almost here.",
priority = 5,
action = {}
target = HomeActionTarget.DatePlan
)
}
// 6. Capsule unlocked (placeholder until capsule data is wired)
if (hasUnlockedCapsule()) {
actions += PendingActionCard(
title = "Capsule unlocked",
subtitle = "A saved memory is ready to open together.",
priority = 6,
action = {}
target = HomeActionTarget.MemoryCapsule
)
}