@droppii-org/chat-mobile 0.2.85 → 0.2.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/components/ThreadCard/ThreadCard.js +14 -5
- package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
- package/lib/module/core/useChatListener.js +9 -3
- package/lib/module/core/useChatListener.js.map +1 -1
- package/lib/module/hooks/groups/useLeaveGroup.js +45 -15
- package/lib/module/hooks/groups/useLeaveGroup.js.map +1 -1
- package/lib/module/hooks/message/useMessages.js +19 -3
- package/lib/module/hooks/message/useMessages.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetail.js +2 -1
- package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +47 -8
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
- package/lib/module/screens/chat-detail/components/MentionSuggestionList.js +16 -6
- package/lib/module/screens/chat-detail/components/MentionSuggestionList.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/LegendChatDay.js +3 -6
- package/lib/module/screens/chat-detail/legend/LegendChatDay.js.map +1 -1
- package/lib/module/translation/resources/i18n.js +2 -2
- package/lib/module/translation/resources/i18n.js.map +1 -1
- package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
- package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
- package/lib/typescript/src/hooks/groups/useLeaveGroup.d.ts.map +1 -1
- package/lib/typescript/src/hooks/message/useMessages.d.ts +3 -1
- package/lib/typescript/src/hooks/message/useMessages.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/components/MentionSuggestionList.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatDay.d.ts +1 -6
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatDay.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/ThreadCard/ThreadCard.tsx +20 -3
- package/src/core/useChatListener.ts +17 -3
- package/src/hooks/groups/{useLeaveGroup.ts → useLeaveGroup.tsx} +45 -22
- package/src/hooks/message/useMessages.ts +26 -2
- package/src/screens/chat-detail/ChatDetail.tsx +5 -1
- package/src/screens/chat-detail/ChatListLegend.tsx +61 -10
- package/src/screens/chat-detail/components/MentionSuggestionList.tsx +16 -6
- package/src/screens/chat-detail/legend/LegendChatDay.tsx +17 -27
- package/src/translation/resources/i18n.ts +2 -2
|
@@ -145,6 +145,10 @@ export const ChatListLegend = memo(
|
|
|
145
145
|
const isAtBottomRef = useRef(true);
|
|
146
146
|
const scrollDebounceRef = useRef<NodeJS.Timeout | undefined>(undefined);
|
|
147
147
|
const rowRefsMap = useRef<Map<string, View | null>>(new Map());
|
|
148
|
+
// Flips true once LegendList's onLoad fires (initial layout + initial
|
|
149
|
+
// scroll both settled) — before that, onStartReached/onEndReached can
|
|
150
|
+
// fire purely from resting scroll position, not a real user gesture.
|
|
151
|
+
const hasSettledRef = useRef(false);
|
|
148
152
|
const [showBadge, setShowBadge] = useState(false);
|
|
149
153
|
const [highlightedId, setHighlightedId] = useState<string | null>(null);
|
|
150
154
|
const highlightTimerRef = useRef<ReturnType<typeof setTimeout> | null>(
|
|
@@ -226,7 +230,7 @@ export const ChatListLegend = memo(
|
|
|
226
230
|
return (
|
|
227
231
|
<>
|
|
228
232
|
{(dayStart || timeBreak) && (
|
|
229
|
-
<LegendChatDay createdAt={createdAt}
|
|
233
|
+
<LegendChatDay createdAt={createdAt} />
|
|
230
234
|
)}
|
|
231
235
|
<KContainer.View
|
|
232
236
|
ref={(node: View | null) => {
|
|
@@ -453,23 +457,51 @@ export const ChatListLegend = memo(
|
|
|
453
457
|
);
|
|
454
458
|
|
|
455
459
|
const handleStartReached = useCallback(() => {
|
|
460
|
+
const willLoad = hasMoreOld && !moreOldLoading;
|
|
456
461
|
if (__DEV__) {
|
|
457
|
-
console.log(
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
+
console.log(
|
|
463
|
+
willLoad && !hasSettledRef.current
|
|
464
|
+
? '[LegendList] ⚠️ onStartReached SPURIOUS mount-time load'
|
|
465
|
+
: '[LegendList] onStartReached triggered',
|
|
466
|
+
{
|
|
467
|
+
conversationId,
|
|
468
|
+
messagesLength: messages.length,
|
|
469
|
+
firstMessageId:
|
|
470
|
+
messages[0]?.clientMsgID || messages[0]?.serverMsgID,
|
|
471
|
+
hasMoreOld,
|
|
472
|
+
moreOldLoading,
|
|
473
|
+
willLoad,
|
|
474
|
+
duringInitialSettle: !hasSettledRef.current,
|
|
475
|
+
}
|
|
476
|
+
);
|
|
462
477
|
}
|
|
463
|
-
if (
|
|
478
|
+
if (willLoad) {
|
|
464
479
|
onLoadMoreOld?.(true);
|
|
465
480
|
}
|
|
466
|
-
}, [hasMoreOld, moreOldLoading, onLoadMoreOld]);
|
|
481
|
+
}, [conversationId, messages, hasMoreOld, moreOldLoading, onLoadMoreOld]);
|
|
467
482
|
|
|
468
483
|
const handleEndReached = useCallback(() => {
|
|
469
|
-
|
|
484
|
+
const willLoad = hasMoreNew && !moreNewLoading;
|
|
485
|
+
if (__DEV__) {
|
|
486
|
+
console.log(
|
|
487
|
+
willLoad && !hasSettledRef.current
|
|
488
|
+
? '[LegendList] ⚠️ onEndReached SPURIOUS mount-time load'
|
|
489
|
+
: '[LegendList] onEndReached triggered',
|
|
490
|
+
{
|
|
491
|
+
conversationId,
|
|
492
|
+
messagesLength: messages.length,
|
|
493
|
+
lastMessageId: messages[messages.length - 1]?.clientMsgID,
|
|
494
|
+
hasMoreNew,
|
|
495
|
+
moreNewLoading,
|
|
496
|
+
willLoad,
|
|
497
|
+
duringInitialSettle: !hasSettledRef.current,
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
if (willLoad) {
|
|
470
502
|
onLoadMoreNew?.(true);
|
|
471
503
|
}
|
|
472
|
-
}, [hasMoreNew, moreNewLoading, onLoadMoreNew]);
|
|
504
|
+
}, [conversationId, messages, hasMoreNew, moreNewLoading, onLoadMoreNew]);
|
|
473
505
|
|
|
474
506
|
const handleScroll = useCallback(
|
|
475
507
|
(e: any) => {
|
|
@@ -527,6 +559,14 @@ export const ChatListLegend = memo(
|
|
|
527
559
|
};
|
|
528
560
|
}, []);
|
|
529
561
|
|
|
562
|
+
// Debug-only: this component can stay mounted across a conversationId
|
|
563
|
+
// change (e.g. navigation.replace reusing the same screen instance), so
|
|
564
|
+
// hasSettledRef must reset per-conversation for the spurious-load log
|
|
565
|
+
// above to stay accurate for the newly opened conversation.
|
|
566
|
+
useEffect(() => {
|
|
567
|
+
hasSettledRef.current = false;
|
|
568
|
+
}, [conversationId]);
|
|
569
|
+
|
|
530
570
|
useEffect(() => {
|
|
531
571
|
const bottomSubscription = DeviceEventEmitter.addListener(
|
|
532
572
|
ChatEvent.ScrollToBottom,
|
|
@@ -598,6 +638,7 @@ export const ChatListLegend = memo(
|
|
|
598
638
|
);
|
|
599
639
|
}
|
|
600
640
|
|
|
641
|
+
console.log('messages length: ', +messages.length);
|
|
601
642
|
return (
|
|
602
643
|
<KContainer.View flex background={KColors.white} style={styles.container}>
|
|
603
644
|
<ListComponent
|
|
@@ -621,6 +662,16 @@ export const ChatListLegend = memo(
|
|
|
621
662
|
ListHeaderComponent={
|
|
622
663
|
<LegendChatLoadEarlier isLoading={moreOldLoading} />
|
|
623
664
|
}
|
|
665
|
+
onLoad={(info: { elapsedTimeInMs: number }) => {
|
|
666
|
+
hasSettledRef.current = true;
|
|
667
|
+
if (__DEV__) {
|
|
668
|
+
console.log('[LegendList] onLoad (initial settle done)', {
|
|
669
|
+
conversationId,
|
|
670
|
+
messagesLength: messages.length,
|
|
671
|
+
elapsedTimeInMs: info.elapsedTimeInMs,
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
}}
|
|
624
675
|
onStartReached={handleStartReached}
|
|
625
676
|
onStartReachedThreshold={0.5}
|
|
626
677
|
onEndReached={handleEndReached}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo, useCallback } from 'react';
|
|
2
2
|
import { ActivityIndicator, StyleSheet } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { FlatList } from 'react-native-gesture-handler';
|
|
4
4
|
import { KContainer, KLabel, KColors, KSpacingValue } from '@droppii/libs';
|
|
5
5
|
import { MentionSuggestionItem } from './MentionSuggestionItem';
|
|
6
6
|
import { trans } from '../../../translation';
|
|
@@ -11,8 +11,9 @@ import type { MentionSuggestion } from '../../../types/mention';
|
|
|
11
11
|
// used as the shared estimate since most rows are the single-line kind.
|
|
12
12
|
const ROW_HEIGHT = 40;
|
|
13
13
|
const ROW_GAP = 8;
|
|
14
|
-
const MAX_VISIBLE_ROWS =
|
|
15
|
-
|
|
14
|
+
const MAX_VISIBLE_ROWS = 5;
|
|
15
|
+
// Fixed, not a cap — see listWrapper's `height` below for why.
|
|
16
|
+
const PANEL_HEIGHT =
|
|
16
17
|
ROW_HEIGHT * MAX_VISIBLE_ROWS + ROW_GAP * (MAX_VISIBLE_ROWS - 1);
|
|
17
18
|
|
|
18
19
|
interface MentionSuggestionListProps {
|
|
@@ -86,11 +87,10 @@ export const MentionSuggestionList = memo(
|
|
|
86
87
|
</KContainer.View>
|
|
87
88
|
) : (
|
|
88
89
|
<KContainer.View style={styles.listWrapper} padding="0.5rem">
|
|
89
|
-
<
|
|
90
|
+
<FlatList
|
|
90
91
|
data={suggestions}
|
|
91
92
|
renderItem={renderItem}
|
|
92
93
|
keyExtractor={keyExtractor}
|
|
93
|
-
estimatedItemSize={ROW_HEIGHT}
|
|
94
94
|
keyboardShouldPersistTaps="handled"
|
|
95
95
|
onEndReached={hasMore ? onLoadMore : undefined}
|
|
96
96
|
onEndReachedThreshold={0.5}
|
|
@@ -124,8 +124,18 @@ const styles = StyleSheet.create({
|
|
|
124
124
|
borderTopRightRadius: KSpacingValue['0.75rem'],
|
|
125
125
|
overflow: 'hidden',
|
|
126
126
|
},
|
|
127
|
+
// Fixed `height`, not `maxHeight` — the panel is absolutely positioned
|
|
128
|
+
// with only `bottom` set (no `top`, see ChatComposer.tsx's mentionPanel
|
|
129
|
+
// style), so its height would otherwise have to be inferred from content
|
|
130
|
+
// through several nested Views. On Android that left the touch/hit-test
|
|
131
|
+
// bounds out of sync with what was actually painted, so drags over the
|
|
132
|
+
// list fell through to the message list rendered underneath instead of
|
|
133
|
+
// scrolling this one. A concrete `height` gives Yoga a definite box from
|
|
134
|
+
// the very first layout pass. Fixed at 5 rows regardless of result count
|
|
135
|
+
// so the scrollable area — and the load-more trigger — stays available
|
|
136
|
+
// even when fewer than 5 suggestions are loaded yet.
|
|
127
137
|
listWrapper: {
|
|
128
|
-
|
|
138
|
+
height: PANEL_HEIGHT,
|
|
129
139
|
},
|
|
130
140
|
separator: {
|
|
131
141
|
height: ROW_GAP,
|
|
@@ -43,35 +43,25 @@ const formatDayLabel = (createdAt: number): string | null => {
|
|
|
43
43
|
|
|
44
44
|
interface LegendChatDayProps {
|
|
45
45
|
createdAt: number;
|
|
46
|
-
/**
|
|
47
|
-
* Render just the clock time, without the day. Used where a cluster broke on
|
|
48
|
-
* elapsed time inside a single day — the date is already on screen above.
|
|
49
|
-
*/
|
|
50
|
-
timeOnly?: boolean;
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
export const LegendChatDay = memo(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<KContainer.View>
|
|
68
|
-
<KLabel.Text typo="TextXsNormal" color={CHAT_BUBBLE_COLORS.dayLabel}>
|
|
69
|
-
{dateStr}
|
|
70
|
-
</KLabel.Text>
|
|
71
|
-
</KContainer.View>
|
|
48
|
+
export const LegendChatDay = memo(({ createdAt }: LegendChatDayProps) => {
|
|
49
|
+
const dateStr = useMemo(() => {
|
|
50
|
+
if (createdAt == null) return null;
|
|
51
|
+
return formatDayLabel(createdAt);
|
|
52
|
+
}, [createdAt]);
|
|
53
|
+
|
|
54
|
+
if (!dateStr) return null;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<KContainer.View center marginV="0.5rem">
|
|
58
|
+
<KContainer.View>
|
|
59
|
+
<KLabel.Text typo="TextXsNormal" color={CHAT_BUBBLE_COLORS.dayLabel}>
|
|
60
|
+
{dateStr}
|
|
61
|
+
</KLabel.Text>
|
|
72
62
|
</KContainer.View>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
);
|
|
63
|
+
</KContainer.View>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
76
66
|
|
|
77
67
|
LegendChatDay.displayName = 'LegendChatDay';
|
|
@@ -141,9 +141,9 @@ const i18nKey: Record<string, string> = {
|
|
|
141
141
|
'chat:info_leave_group': 'Rời nhóm',
|
|
142
142
|
'chat:leave_group_confirm_title': 'Rời nhóm?',
|
|
143
143
|
'chat:leave_group_confirm_desc_private':
|
|
144
|
-
'Sau khi rời nhóm, bạn sẽ không thể xem tin nhắn từ cuộc trò chuyện này nữa. Bạn có chắc chắn muốn rời khỏi nhóm
|
|
144
|
+
'Sau khi rời nhóm, bạn sẽ không thể xem tin nhắn từ cuộc trò chuyện này nữa. Bạn có chắc chắn muốn <bold>rời khỏi nhóm</bold>?',
|
|
145
145
|
'chat:leave_group_confirm_desc_public':
|
|
146
|
-
'Sau khi rời nhóm, bạn sẽ không thể nhắn tin hay nhận thông báo từ cuộc trò chuyện này nữa. Bạn có chắc chắn muốn rời khỏi nhóm
|
|
146
|
+
'Sau khi rời nhóm, bạn sẽ không thể nhắn tin hay nhận thông báo từ cuộc trò chuyện này nữa. Bạn có chắc chắn muốn <bold>rời khỏi nhóm</bold>?',
|
|
147
147
|
'chat:leave_group_confirm_primary': 'Rời nhóm',
|
|
148
148
|
'chat:leave_group_confirm_secondary': 'Ở lại nhóm',
|
|
149
149
|
'chat:leave_group_blocked_title': 'Không thể rời nhóm',
|