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:
parent
af67194117
commit
903498ef4d
|
|
@ -119,7 +119,7 @@ object WeeklyRecapGenerator {
|
||||||
|
|
||||||
val byFavorite = favoriteCategory?.let { cat ->
|
val byFavorite = favoriteCategory?.let { cat ->
|
||||||
availablePacks
|
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 } }
|
.maxByOrNull { it.categoryIds.count { id -> id == cat } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,17 +108,6 @@ fun HomeScreen(
|
||||||
onInvite = { onNavigate(AppRoute.CREATE_INVITE) },
|
onInvite = { onNavigate(AppRoute.CREATE_INVITE) },
|
||||||
onReminder = viewModel::sendGentleReminder,
|
onReminder = viewModel::sendGentleReminder,
|
||||||
onReveal = { state.dailyQuestion?.id?.let { onNavigate(AppRoute.answerReveal(it)) } },
|
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)) } },
|
onFollowUp = { state.dailyQuestion?.let { onNavigate(AppRoute.questionThread(state.coupleId ?: "", it.id)) } },
|
||||||
onRefresh = viewModel::loadHome
|
onRefresh = viewModel::loadHome
|
||||||
)
|
)
|
||||||
|
|
@ -129,7 +118,6 @@ data class HomeCallbacks(
|
||||||
val onReminder: () -> Unit,
|
val onReminder: () -> Unit,
|
||||||
val onReveal: () -> Unit,
|
val onReveal: () -> Unit,
|
||||||
val onFollowUp: () -> Unit,
|
val onFollowUp: () -> Unit,
|
||||||
val onPendingAction: (PendingActionCard) -> Unit,
|
|
||||||
val onPacks: () -> Unit,
|
val onPacks: () -> Unit,
|
||||||
val onCategory: (String) -> Unit,
|
val onCategory: (String) -> Unit,
|
||||||
val onHistory: () -> Unit,
|
val onHistory: () -> Unit,
|
||||||
|
|
@ -167,11 +155,10 @@ private fun HomeContent(
|
||||||
onReminder: () -> Unit,
|
onReminder: () -> Unit,
|
||||||
onReveal: () -> Unit,
|
onReveal: () -> Unit,
|
||||||
onFollowUp: () -> Unit,
|
onFollowUp: () -> Unit,
|
||||||
onPendingAction: (PendingActionCard) -> Unit,
|
|
||||||
onRefresh: () -> Unit
|
onRefresh: () -> Unit
|
||||||
) {
|
) {
|
||||||
val callbacks = remember(
|
val callbacks = remember(
|
||||||
onDailyQuestion, onReminder, onReveal, onFollowUp, onPendingAction,
|
onDailyQuestion, onReminder, onReveal, onFollowUp,
|
||||||
onPacks, onCategory, onHistory, onSettings, onInvite, onRefresh
|
onPacks, onCategory, onHistory, onSettings, onInvite, onRefresh
|
||||||
) {
|
) {
|
||||||
HomeCallbacks(
|
HomeCallbacks(
|
||||||
|
|
@ -179,7 +166,6 @@ private fun HomeContent(
|
||||||
onReminder = onReminder,
|
onReminder = onReminder,
|
||||||
onReveal = onReveal,
|
onReveal = onReveal,
|
||||||
onFollowUp = onFollowUp,
|
onFollowUp = onFollowUp,
|
||||||
onPendingAction = onPendingAction,
|
|
||||||
onPacks = onPacks,
|
onPacks = onPacks,
|
||||||
onCategory = onCategory,
|
onCategory = onCategory,
|
||||||
onHistory = onHistory,
|
onHistory = onHistory,
|
||||||
|
|
@ -190,8 +176,16 @@ private fun HomeContent(
|
||||||
}
|
}
|
||||||
val onActionSelected = callbacks.toActionHandler(onNavigate)
|
val onActionSelected = callbacks.toActionHandler(onNavigate)
|
||||||
val onPendingActionSelected: (PendingActionCard) -> Unit = { card ->
|
val onPendingActionSelected: (PendingActionCard) -> Unit = { card ->
|
||||||
card.action()
|
onActionSelected(
|
||||||
callbacks.onPendingAction(card)
|
HomeAction(
|
||||||
|
eyebrow = "",
|
||||||
|
title = "",
|
||||||
|
body = "",
|
||||||
|
cta = "",
|
||||||
|
target = card.target,
|
||||||
|
tone = HomeActionTone.Daily
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -967,7 +961,6 @@ fun HomeScreenPreview() {
|
||||||
onHistory = {},
|
onHistory = {},
|
||||||
onSettings = {},
|
onSettings = {},
|
||||||
onInvite = {},
|
onInvite = {},
|
||||||
onPendingAction = {},
|
|
||||||
onRefresh = {}
|
onRefresh = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ data class PendingActionCard(
|
||||||
val title: String,
|
val title: String,
|
||||||
val subtitle: String?,
|
val subtitle: String?,
|
||||||
val priority: Int,
|
val priority: Int,
|
||||||
val action: () -> Unit
|
val target: HomeActionTarget
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class DailyQuestionState {
|
enum class DailyQuestionState {
|
||||||
|
|
@ -581,63 +581,57 @@ class HomeViewModel @Inject constructor(
|
||||||
|
|
||||||
val actions = mutableListOf<PendingActionCard>()
|
val actions = mutableListOf<PendingActionCard>()
|
||||||
|
|
||||||
// 1. Reveal ready (highest priority)
|
|
||||||
if (dailyQuestionState == DailyQuestionState.BOTH_ANSWERED) {
|
if (dailyQuestionState == DailyQuestionState.BOTH_ANSWERED) {
|
||||||
actions += PendingActionCard(
|
actions += PendingActionCard(
|
||||||
title = "Reveal is ready",
|
title = "Reveal is ready",
|
||||||
subtitle = "Both of you answered tonight. Open it together.",
|
subtitle = "Both of you answered tonight. Open it together.",
|
||||||
priority = 1,
|
priority = 1,
|
||||||
action = {}
|
target = HomeActionTarget.AnswerReveal
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Partner answered, waiting for user
|
|
||||||
if (dailyQuestionState == DailyQuestionState.PARTNER_ANSWERED_USER_PENDING) {
|
if (dailyQuestionState == DailyQuestionState.PARTNER_ANSWERED_USER_PENDING) {
|
||||||
actions += PendingActionCard(
|
actions += PendingActionCard(
|
||||||
title = "Your partner answered",
|
title = "Your partner answered",
|
||||||
subtitle = "Answer tonight’s question to unlock the reveal.",
|
subtitle = "Answer tonight’s question to unlock the reveal.",
|
||||||
priority = 2,
|
priority = 2,
|
||||||
action = {}
|
target = HomeActionTarget.DailyQuestion
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Game waiting (placeholder until QuestionSessionRepository is wired)
|
|
||||||
if (hasWaitingGame()) {
|
if (hasWaitingGame()) {
|
||||||
actions += PendingActionCard(
|
actions += PendingActionCard(
|
||||||
title = "Game waiting",
|
title = "Game waiting",
|
||||||
subtitle = "Your turn to play a game together.",
|
subtitle = "Your turn to play a game together.",
|
||||||
priority = 3,
|
priority = 3,
|
||||||
action = {}
|
target = HomeActionTarget.Game
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Challenge incomplete (placeholder until challenge data is wired)
|
|
||||||
if (hasIncompleteChallenge()) {
|
if (hasIncompleteChallenge()) {
|
||||||
actions += PendingActionCard(
|
actions += PendingActionCard(
|
||||||
title = "Challenge waiting",
|
title = "Challenge waiting",
|
||||||
subtitle = "Today’s small step is ready for both of you.",
|
subtitle = "Today’s small step is ready for both of you.",
|
||||||
priority = 4,
|
priority = 4,
|
||||||
action = {}
|
target = HomeActionTarget.Challenge
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Date reminder (placeholder until DatePlanRepository is wired)
|
|
||||||
if (hasUpcomingDate()) {
|
if (hasUpcomingDate()) {
|
||||||
actions += PendingActionCard(
|
actions += PendingActionCard(
|
||||||
title = "Date coming up",
|
title = "Date coming up",
|
||||||
subtitle = "A planned moment is almost here.",
|
subtitle = "A planned moment is almost here.",
|
||||||
priority = 5,
|
priority = 5,
|
||||||
action = {}
|
target = HomeActionTarget.DatePlan
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Capsule unlocked (placeholder until capsule data is wired)
|
|
||||||
if (hasUnlockedCapsule()) {
|
if (hasUnlockedCapsule()) {
|
||||||
actions += PendingActionCard(
|
actions += PendingActionCard(
|
||||||
title = "Capsule unlocked",
|
title = "Capsule unlocked",
|
||||||
subtitle = "A saved memory is ready to open together.",
|
subtitle = "A saved memory is ready to open together.",
|
||||||
priority = 6,
|
priority = 6,
|
||||||
action = {}
|
target = HomeActionTarget.MemoryCapsule
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue