@@ -92,6 +92,7 @@ import com.anytypeio.anytype.feature_chats.presentation.ChatViewModel.MentionPan
92
92
import com.anytypeio.anytype.feature_chats.presentation.ChatViewModel.UXCommand
93
93
import com.anytypeio.anytype.feature_chats.presentation.ChatViewState
94
94
import kotlinx.coroutines.android.awaitFrame
95
+ import kotlinx.coroutines.delay
95
96
import kotlinx.coroutines.flow.distinctUntilChanged
96
97
import kotlinx.coroutines.flow.filterNotNull
97
98
import kotlinx.coroutines.flow.first
@@ -414,22 +415,33 @@ fun ChatScreen(
414
415
415
416
Timber .d(" DROID-2966 Render called with state, number of messages: ${messages.size} " )
416
417
418
+ val scope = rememberCoroutineScope()
419
+
417
420
var text by rememberSaveable(stateSaver = TextFieldValue .Saver ) {
418
421
mutableStateOf(TextFieldValue ())
419
422
}
420
423
424
+ var highlightedMessageId by remember { mutableStateOf<Id ?>(null ) }
425
+
426
+ val triggerHighlight: (Id ) -> Unit = { id ->
427
+ highlightedMessageId = id
428
+ scope.launch {
429
+ delay(1000 )
430
+ highlightedMessageId = null
431
+ }
432
+ }
433
+
421
434
var spans by remember { mutableStateOf<List <ChatBoxSpan >>(emptyList()) }
422
435
423
436
val chatBoxFocusRequester = FocusRequester ()
424
437
425
- val scope = rememberCoroutineScope()
426
-
427
438
val isPerformingScrollIntent = remember { mutableStateOf(false ) }
428
439
429
440
val offsetPx = with (LocalDensity .current) { 50 .dp.toPx().toInt() }
430
441
431
442
// Applying view model intents
432
443
LaunchedEffect (intent) {
444
+ Timber .d(" DROID-2966 New intent: $intent " )
433
445
when (intent) {
434
446
is ChatContainer .Intent .ScrollToMessage -> {
435
447
isPerformingScrollIntent.value = true
@@ -449,6 +461,12 @@ fun ChatScreen(
449
461
}
450
462
}
451
463
awaitFrame()
464
+
465
+ if (intent.highlight) {
466
+ highlightedMessageId = intent.id
467
+ delay(500 )
468
+ highlightedMessageId = null
469
+ }
452
470
} else {
453
471
Timber .d(" DROID-2966 COMPOSE Could not find the scrolling target for the intent" )
454
472
}
@@ -463,9 +481,6 @@ fun ChatScreen(
463
481
isPerformingScrollIntent.value = false
464
482
onClearIntent()
465
483
}
466
- is ChatContainer .Intent .Highlight -> {
467
- // maybe flash background, etc.
468
- }
469
484
ChatContainer .Intent .None -> Unit
470
485
}
471
486
}
@@ -595,7 +610,9 @@ fun ChatScreen(
595
610
isReadOnly = isReadOnly,
596
611
onShareInviteClicked = onShareInviteClicked,
597
612
canCreateInviteLink = canCreateInviteLink,
598
- onRequestVideoPlayer = onRequestVideoPlayer
613
+ onRequestVideoPlayer = onRequestVideoPlayer,
614
+ highlightedMessageId = highlightedMessageId,
615
+ onHighlightMessage = triggerHighlight
599
616
)
600
617
601
618
GoToMentionButton (
@@ -853,10 +870,12 @@ fun Messages(
853
870
onMemberIconClicked : (Id ? ) -> Unit ,
854
871
onMentionClicked : (Id ) -> Unit ,
855
872
onScrollToReplyClicked : (Id ) -> Unit ,
873
+ onHighlightMessage : (Id ) -> Unit ,
856
874
onShareInviteClicked : () -> Unit ,
857
875
canCreateInviteLink : Boolean = false,
858
876
isReadOnly : Boolean = false,
859
- onRequestVideoPlayer : (ChatView .Message .Attachment .Video ) -> Unit
877
+ onRequestVideoPlayer : (ChatView .Message .Attachment .Video ) -> Unit ,
878
+ highlightedMessageId : Id ?
860
879
) {
861
880
// Timber.d("DROID-2966 Messages composition: ${messages.map { if (it is ChatView.Message) it.content.msg else it }}")
862
881
val scope = rememberCoroutineScope()
@@ -876,6 +895,9 @@ fun Messages(
876
895
}
877
896
) { idx, msg ->
878
897
if (msg is ChatView .Message ) {
898
+
899
+ val isHighlighted = msg.id == highlightedMessageId
900
+
879
901
if (idx == 0 )
880
902
Spacer (modifier = Modifier .height(36 .dp))
881
903
Row (
@@ -935,6 +957,7 @@ fun Messages(
935
957
scope.launch {
936
958
if (targetIndex != - 1 && targetIndex < scrollState.layoutInfo.totalItemsCount) {
937
959
scrollState.animateScrollToItem(index = targetIndex)
960
+ onHighlightMessage(reply.msg)
938
961
} else {
939
962
// Defer to VM: message likely not yet in the list (e.g. paged)
940
963
onScrollToReplyClicked(reply.msg)
@@ -949,7 +972,8 @@ fun Messages(
949
972
},
950
973
onMentionClicked = onMentionClicked,
951
974
isReadOnly = isReadOnly,
952
- onRequestVideoPlayer = onRequestVideoPlayer
975
+ onRequestVideoPlayer = onRequestVideoPlayer,
976
+ isHighlighted = isHighlighted
953
977
)
954
978
}
955
979
if (idx == messages.lastIndex) {
0 commit comments