@@ -11,6 +11,7 @@ import androidx.compose.ui.platform.testTag
1111import androidx.lifecycle.compose.collectAsStateWithLifecycle
1212import androidx.paging.compose.collectAsLazyPagingItems
1313import com.flipcash.app.core.AppRoute
14+ import com.flipcash.app.core.chat.ChatStep
1415import com.flipcash.app.messenger.internal.ChatViewModel
1516import com.flipcash.app.messenger.internal.screens.components.ChatTopBar
1617import com.flipcash.app.messenger.internal.screens.components.MessageList
@@ -31,8 +32,51 @@ internal fun MessengerScreen(viewModel: ChatViewModel) {
3132 val hazeState = rememberHazeState()
3233 val keyboard = rememberKeyboardController()
3334
35+ val chatActionHandler = { action: ChatAction ->
36+ when (action) {
37+ is ChatAction .AdvanceReadPointer -> {
38+ viewModel.dispatchEvent(ChatViewModel .Event .AdvanceReadPointer (action.messageId))
39+ }
40+
41+ ChatAction .RefreshContact -> {
42+ viewModel.dispatchEvent(ChatViewModel .Event .RefreshContact )
43+ }
44+
45+ is ChatAction .RetryMessage -> {
46+ keyboard.hideIfVisible {
47+ viewModel.dispatchEvent(
48+ ChatViewModel .Event .RetryMessage (
49+ action.bubble.pendingClientIdHex,
50+ action.bubble.content
51+ )
52+ )
53+ }
54+ }
55+
56+ is ChatAction .ViewToken -> {
57+ keyboard.hideIfVisible {
58+ viewModel.dispatchEvent(
59+ ChatViewModel .Event .OpenScreen (AppRoute .Token .Info (action.mint))
60+ )
61+ }
62+ }
63+
64+ is ChatAction .ViewProfile -> {
65+ // The triggers (top-bar tap, contact-card chevron) are only clickable when the
66+ // Blocklist beta flag is on, so no gating is needed here.
67+ state.participant?.let {
68+ keyboard.hideIfVisible {
69+ navigator.push(ChatStep .Profile (it))
70+ }
71+ }
72+ }
73+ }
74+
75+ Unit
76+ }
77+
3478 ChatInputScaffold (
35- topBar = { ChatTopBar (navigator, state.participant ) },
79+ topBar = { ChatTopBar (navigator, state, chatActionHandler ) },
3680 bottomBar = {
3781 UserControlBottomBar (
3882 state = state,
@@ -51,36 +95,8 @@ internal fun MessengerScreen(viewModel: ChatViewModel) {
5195 messages = messages,
5296 separatorConfig = state.separatorConfig,
5397 otherReadPointer = otherReadPointer,
54- onAction = { action ->
55- when (action) {
56- is ChatAction .AdvanceReadPointer -> {
57- viewModel.dispatchEvent(ChatViewModel .Event .AdvanceReadPointer (action.messageId))
58- }
59-
60- ChatAction .RefreshContact -> {
61- viewModel.dispatchEvent(ChatViewModel .Event .RefreshContact )
62- }
63-
64- is ChatAction .RetryMessage -> {
65- keyboard.hideIfVisible {
66- viewModel.dispatchEvent(
67- ChatViewModel .Event .RetryMessage (
68- action.bubble.pendingClientIdHex,
69- action.bubble.content
70- )
71- )
72- }
73- }
74-
75- is ChatAction .ViewToken -> {
76- keyboard.hideIfVisible {
77- viewModel.dispatchEvent(
78- ChatViewModel .Event .OpenScreen (AppRoute .Token .Info (action.mint))
79- )
80- }
81- }
82- }
83- },
98+ onAction = chatActionHandler,
99+ canViewProfile = state.canViewProfile,
84100 )
85101 }
86102}
0 commit comments