@droppii-org/chat-mobile 0.2.78 → 0.2.80

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.
Files changed (140) hide show
  1. package/lib/module/components/messages/BubbleTail.js +31 -0
  2. package/lib/module/components/messages/BubbleTail.js.map +1 -0
  3. package/lib/module/components/messages/BubbleTailRow.js +46 -0
  4. package/lib/module/components/messages/BubbleTailRow.js.map +1 -0
  5. package/lib/module/components/messages/bubbleTail.utils.js +19 -0
  6. package/lib/module/components/messages/bubbleTail.utils.js.map +1 -0
  7. package/lib/module/components/messages/fileMessage/index.js +72 -65
  8. package/lib/module/components/messages/fileMessage/index.js.map +1 -1
  9. package/lib/module/components/messages/imageMessage/index.js +23 -17
  10. package/lib/module/components/messages/imageMessage/index.js.map +1 -1
  11. package/lib/module/components/messages/linkMessage/index.js +11 -23
  12. package/lib/module/components/messages/linkMessage/index.js.map +1 -1
  13. package/lib/module/components/messages/mergedMessage/index.js +14 -7
  14. package/lib/module/components/messages/mergedMessage/index.js.map +1 -1
  15. package/lib/module/components/messages/quotedMessage/index.js +11 -23
  16. package/lib/module/components/messages/quotedMessage/index.js.map +1 -1
  17. package/lib/module/components/messages/revokedMessage/index.js +14 -7
  18. package/lib/module/components/messages/revokedMessage/index.js.map +1 -1
  19. package/lib/module/components/messages/stickerMessage/index.js +13 -7
  20. package/lib/module/components/messages/stickerMessage/index.js.map +1 -1
  21. package/lib/module/components/messages/textMessage/index.js +11 -26
  22. package/lib/module/components/messages/textMessage/index.js.map +1 -1
  23. package/lib/module/components/messages/types.js.map +1 -1
  24. package/lib/module/components/messages/videoMessage/index.js +16 -8
  25. package/lib/module/components/messages/videoMessage/index.js.map +1 -1
  26. package/lib/module/core/useChatListener.js +11 -0
  27. package/lib/module/core/useChatListener.js.map +1 -1
  28. package/lib/module/hooks/groups/useDismissGroup.js +2 -1
  29. package/lib/module/hooks/groups/useDismissGroup.js.map +1 -1
  30. package/lib/module/hooks/groups/useGroupAccessGuard.js +145 -0
  31. package/lib/module/hooks/groups/useGroupAccessGuard.js.map +1 -0
  32. package/lib/module/screens/ChatInfo/ChatInfoDescriptionRow.js +4 -1
  33. package/lib/module/screens/ChatInfo/ChatInfoDescriptionRow.js.map +1 -1
  34. package/lib/module/screens/chat-detail/ChatDetail.js +12 -10
  35. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  36. package/lib/module/screens/chat-detail/ChatDetailHeader.js +3 -9
  37. package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
  38. package/lib/module/screens/chat-detail/ChatListLegend.js +71 -21
  39. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  40. package/lib/module/screens/chat-detail/legend/LegendChatDay.js +8 -2
  41. package/lib/module/screens/chat-detail/legend/LegendChatDay.js.map +1 -1
  42. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +38 -13
  43. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
  44. package/lib/module/screens/inbox/CommunityTab.js +5 -2
  45. package/lib/module/screens/inbox/CommunityTab.js.map +1 -1
  46. package/lib/module/screens/inbox/MessagesTab.js +2 -2
  47. package/lib/module/screens/inbox/MessagesTab.js.map +1 -1
  48. package/lib/module/store/conversation.js +18 -20
  49. package/lib/module/store/conversation.js.map +1 -1
  50. package/lib/module/translation/resources/i18n.js +4 -1
  51. package/lib/module/translation/resources/i18n.js.map +1 -1
  52. package/lib/module/utils/conversation.js +4 -1
  53. package/lib/module/utils/conversation.js.map +1 -1
  54. package/lib/module/utils/legendListMessage.js +86 -12
  55. package/lib/module/utils/legendListMessage.js.map +1 -1
  56. package/lib/module/utils/message.js +19 -1
  57. package/lib/module/utils/message.js.map +1 -1
  58. package/lib/module/utils/messageUtils.js +7 -1
  59. package/lib/module/utils/messageUtils.js.map +1 -1
  60. package/lib/typescript/src/components/messages/BubbleTail.d.ts +13 -0
  61. package/lib/typescript/src/components/messages/BubbleTail.d.ts.map +1 -0
  62. package/lib/typescript/src/components/messages/BubbleTailRow.d.ts +25 -0
  63. package/lib/typescript/src/components/messages/BubbleTailRow.d.ts.map +1 -0
  64. package/lib/typescript/src/components/messages/bubbleTail.utils.d.ts +11 -0
  65. package/lib/typescript/src/components/messages/bubbleTail.utils.d.ts.map +1 -0
  66. package/lib/typescript/src/components/messages/fileMessage/index.d.ts +1 -1
  67. package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -1
  68. package/lib/typescript/src/components/messages/imageMessage/index.d.ts +1 -1
  69. package/lib/typescript/src/components/messages/imageMessage/index.d.ts.map +1 -1
  70. package/lib/typescript/src/components/messages/linkMessage/index.d.ts +1 -1
  71. package/lib/typescript/src/components/messages/linkMessage/index.d.ts.map +1 -1
  72. package/lib/typescript/src/components/messages/mergedMessage/index.d.ts +1 -1
  73. package/lib/typescript/src/components/messages/mergedMessage/index.d.ts.map +1 -1
  74. package/lib/typescript/src/components/messages/quotedMessage/index.d.ts.map +1 -1
  75. package/lib/typescript/src/components/messages/revokedMessage/index.d.ts +1 -1
  76. package/lib/typescript/src/components/messages/revokedMessage/index.d.ts.map +1 -1
  77. package/lib/typescript/src/components/messages/stickerMessage/index.d.ts +1 -1
  78. package/lib/typescript/src/components/messages/stickerMessage/index.d.ts.map +1 -1
  79. package/lib/typescript/src/components/messages/textMessage/index.d.ts +1 -1
  80. package/lib/typescript/src/components/messages/textMessage/index.d.ts.map +1 -1
  81. package/lib/typescript/src/components/messages/types.d.ts +3 -0
  82. package/lib/typescript/src/components/messages/types.d.ts.map +1 -1
  83. package/lib/typescript/src/components/messages/videoMessage/index.d.ts +1 -1
  84. package/lib/typescript/src/components/messages/videoMessage/index.d.ts.map +1 -1
  85. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  86. package/lib/typescript/src/hooks/groups/useDismissGroup.d.ts.map +1 -1
  87. package/lib/typescript/src/hooks/groups/useGroupAccessGuard.d.ts +10 -0
  88. package/lib/typescript/src/hooks/groups/useGroupAccessGuard.d.ts.map +1 -0
  89. package/lib/typescript/src/screens/ChatInfo/ChatInfoDescriptionRow.d.ts.map +1 -1
  90. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  91. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts +1 -1
  92. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts.map +1 -1
  93. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
  94. package/lib/typescript/src/screens/chat-detail/legend/LegendChatDay.d.ts +6 -1
  95. package/lib/typescript/src/screens/chat-detail/legend/LegendChatDay.d.ts.map +1 -1
  96. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +14 -1
  97. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
  98. package/lib/typescript/src/screens/chat-detail/types.d.ts +0 -1
  99. package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
  100. package/lib/typescript/src/store/conversation.d.ts.map +1 -1
  101. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  102. package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
  103. package/lib/typescript/src/utils/legendListMessage.d.ts +19 -4
  104. package/lib/typescript/src/utils/legendListMessage.d.ts.map +1 -1
  105. package/lib/typescript/src/utils/message.d.ts +17 -0
  106. package/lib/typescript/src/utils/message.d.ts.map +1 -1
  107. package/lib/typescript/src/utils/messageUtils.d.ts +1 -0
  108. package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
  109. package/package.json +1 -1
  110. package/src/components/messages/BubbleTail.tsx +35 -0
  111. package/src/components/messages/BubbleTailRow.tsx +64 -0
  112. package/src/components/messages/bubbleTail.utils.ts +21 -0
  113. package/src/components/messages/fileMessage/index.tsx +90 -83
  114. package/src/components/messages/imageMessage/index.tsx +26 -23
  115. package/src/components/messages/linkMessage/index.tsx +6 -18
  116. package/src/components/messages/mergedMessage/index.tsx +27 -15
  117. package/src/components/messages/quotedMessage/index.tsx +7 -19
  118. package/src/components/messages/revokedMessage/index.tsx +23 -14
  119. package/src/components/messages/stickerMessage/index.tsx +16 -11
  120. package/src/components/messages/textMessage/index.tsx +6 -22
  121. package/src/components/messages/types.ts +3 -0
  122. package/src/components/messages/videoMessage/index.tsx +13 -10
  123. package/src/core/useChatListener.ts +14 -0
  124. package/src/hooks/groups/useDismissGroup.tsx +1 -0
  125. package/src/hooks/groups/useGroupAccessGuard.ts +182 -0
  126. package/src/screens/ChatInfo/ChatInfoDescriptionRow.tsx +5 -1
  127. package/src/screens/chat-detail/ChatDetail.tsx +11 -13
  128. package/src/screens/chat-detail/ChatDetailHeader.tsx +2 -6
  129. package/src/screens/chat-detail/ChatListLegend.tsx +97 -28
  130. package/src/screens/chat-detail/legend/LegendChatDay.tsx +25 -15
  131. package/src/screens/chat-detail/legend/LegendChatMessage.tsx +62 -12
  132. package/src/screens/chat-detail/types.ts +0 -1
  133. package/src/screens/inbox/CommunityTab.tsx +2 -2
  134. package/src/screens/inbox/MessagesTab.tsx +1 -1
  135. package/src/store/conversation.ts +14 -18
  136. package/src/translation/resources/i18n.ts +4 -0
  137. package/src/utils/conversation.ts +6 -3
  138. package/src/utils/legendListMessage.ts +123 -14
  139. package/src/utils/message.ts +19 -1
  140. package/src/utils/messageUtils.ts +9 -1
@@ -35,9 +35,10 @@ import {
35
35
  type MessageItem,
36
36
  } from '@droppii/openim-rn-client-sdk';
37
37
  import { useMessages } from '../../hooks/message/useMessages';
38
- import { ChatEvent, type GroupRemovedPayload } from '../../types/events';
38
+ import { ChatEvent } from '../../types/events';
39
39
  import { useSetIsShowFLashMessage } from '../../context/global';
40
40
  import { useJoinGroup } from '../../hooks/groups/useJoinGroup';
41
+ import { useGroupAccessGuard } from '../../hooks/groups/useGroupAccessGuard';
41
42
 
42
43
  const ChatDetail = memo(
43
44
  ({
@@ -119,16 +120,14 @@ const ChatDetail = memo(
119
120
  };
120
121
  }, [conversationId, targetUserId, targetGroupId, setShowFLashMessage]);
121
122
 
122
- useEffect(() => {
123
- const sub = DeviceEventEmitter.addListener(
124
- ChatEvent.GroupRemoved,
125
- (payload: GroupRemovedPayload) => {
126
- if (payload.groupID !== targetGroupId) return;
127
- (onBack ?? handleBackDefault)();
128
- }
129
- );
130
- return () => sub.remove();
131
- }, [targetGroupId, onBack, handleBackDefault]);
123
+ const handleAccessBlocked = useCallback(() => {
124
+ (onBack ?? handleBackDefault)();
125
+ }, [onBack, handleBackDefault]);
126
+
127
+ const { isCheckingAccess } = useGroupAccessGuard({
128
+ groupID: conversation?.groupID || targetGroupId,
129
+ onBlocked: handleAccessBlocked,
130
+ });
132
131
 
133
132
  const resolvedShowAddMember =
134
133
  showAddMember ?? shouldShowAddMember(conversation);
@@ -197,7 +196,6 @@ const ChatDetail = memo(
197
196
  onPressAddMember={onPressAddMember}
198
197
  onPressMenu={handlePressMenu}
199
198
  onPressAvatar={handlePressMenu}
200
- targetGroupId={targetGroupId}
201
199
  />
202
200
 
203
201
  <PinnedMessageBar
@@ -210,7 +208,7 @@ const ChatDetail = memo(
210
208
  messages={messages}
211
209
  conversationId={conversationId}
212
210
  customMessageItemFactory={customMessageItemFactory}
213
- isLoading={initLoading || isLoadingConversation}
211
+ isLoading={initLoading || isLoadingConversation || isCheckingAccess}
214
212
  onLoadMoreOld={getMoreOldMessages}
215
213
  hasMoreOld={hasMoreOld}
216
214
  moreOldLoading={moreOldLoading}
@@ -11,8 +11,8 @@ import { NamePrefixIcon } from '../../components/ThreadCard/NamePrefixIcon';
11
11
  import type { ChatDetailHeaderProps } from './types';
12
12
  import { getConversationSubtitle } from './conversationHeader.utils';
13
13
  import { useGetUsersInfo } from '../../hooks/users/useGetUsersInfo';
14
- import { useGetConversationDetail } from '../../hooks/conversation/useGetConversationDetail';
15
14
  import { useChatDetailContext } from '../../context';
15
+ import { useConversation } from '../../store';
16
16
 
17
17
  const ChatDetailHeader = memo(
18
18
  ({
@@ -24,12 +24,8 @@ const ChatDetailHeader = memo(
24
24
  onPressAddMember,
25
25
  onPressMenu,
26
26
  onPressAvatar,
27
- targetGroupId,
28
27
  }: ChatDetailHeaderProps) => {
29
- const { conversationData: conversation } = useGetConversationDetail({
30
- targetGroupId,
31
- targetUserId: targetUserId,
32
- });
28
+ const conversation = useConversation(conversationId);
33
29
  const { data: usersInfo } = useGetUsersInfo(
34
30
  targetUserId ? [targetUserId] : []
35
31
  );
@@ -32,7 +32,11 @@ import {
32
32
  KRadiusValue,
33
33
  KImage,
34
34
  } from '@droppii/libs';
35
- import { precomputeLegendListData } from '../../utils/legendListMessage';
35
+ import {
36
+ precomputeLegendListData,
37
+ type GroupPosition,
38
+ } from '../../utils/legendListMessage';
39
+ import { getMessageRenderId } from '../../utils/message';
36
40
  import type { ChatListProps } from './types';
37
41
  import { LegendChatMessage } from './legend/LegendChatMessage';
38
42
  import { LegendChatDay } from './legend/LegendChatDay';
@@ -50,7 +54,7 @@ import { ChatEvent, type ScrollToMessagePayload } from '../../types/events';
50
54
  import { useMessageStore } from '../../store/message';
51
55
  import { useChatContext } from '../../context';
52
56
  import { messageStyles } from './legend/messageTypes';
53
- import { MessageType } from '@droppii/openim-rn-client-sdk';
57
+ import { MessageType, PeerType } from '@droppii/openim-rn-client-sdk';
54
58
  import type { MessageItem } from '@droppii/openim-rn-client-sdk';
55
59
  import { useUserStore } from '../../store';
56
60
  import { ChatMessageAPI } from '../../services';
@@ -60,10 +64,19 @@ import ChatImageDimens, {
60
64
  CHAT_IMAGE_VIEW_SOURCE,
61
65
  } from '../../utils/chatImageDimens';
62
66
 
63
- // Row wrapper (`messageRowLeft`/`messageRowRight` in `components/messages/styles.ts`)
64
- // adds only a bottom margin no vertical padding so a fixed-size item's true
65
- // rendered height is `content height + this margin`.
66
- const ROW_MARGIN_BOTTOM = KSpacingValue['0.25rem'];
67
+ // Cluster spacing: a wide gap after the message that closes a cluster, a tight
68
+ // one between messages inside it. These override the flat margin on the row
69
+ // wrapper (`messageRowLeft`/`messageRowRight` in `components/messages/styles.ts`),
70
+ // which adds only a bottom margin and no vertical padding — so a fixed-size
71
+ // item's true rendered height stays `content height + this margin`, and
72
+ // getFixedItemSize can keep folding it in.
73
+ const ROW_MARGIN_CLUSTER_END = KSpacingValue['0.5rem'];
74
+ const ROW_MARGIN_IN_CLUSTER = KSpacingValue['0.25rem'];
75
+
76
+ const getRowMarginBottom = (position: GroupPosition): number =>
77
+ position === 'last' || position === 'solo'
78
+ ? ROW_MARGIN_CLUSTER_END
79
+ : ROW_MARGIN_IN_CLUSTER;
67
80
 
68
81
  // KeyboardAwareLegendList auto scroll when modal opened
69
82
  // TODO: Convert toolbox to absolute view
@@ -103,12 +116,23 @@ export const ChatListLegend = memo(
103
116
  const currentUserId = useUserStore((s) => s.user?.userID);
104
117
  const windowWidth = useWindowDimensions().width;
105
118
  // Precompute all message data in single pass (O(n))
119
+ const { isBotConversation, conversationFlow, conversation } =
120
+ useChatDetailContext();
121
+
122
+ // Avatar and sender name only appear in real group chats — a bot thread is
123
+ // a Group session too, but reads as a single counterpart.
124
+ const isGroupConversation =
125
+ conversation?.peerType === PeerType.Group && !isBotConversation;
126
+
106
127
  const messageDataMap = useMemo(
107
- () => precomputeLegendListData(messages),
108
- [messages]
128
+ () =>
129
+ precomputeLegendListData(messages, {
130
+ isBotConversation,
131
+ currentUserId,
132
+ }),
133
+ [messages, isBotConversation, currentUserId]
109
134
  );
110
135
 
111
- const { isBotConversation, conversationFlow } = useChatDetailContext();
112
136
  const { retryMessage } = useSendMessage();
113
137
 
114
138
  const lastMessageId = useMemo(() => {
@@ -163,17 +187,22 @@ export const ChatListLegend = memo(
163
187
  const isLastMessage =
164
188
  (message.clientMsgID || message.serverMsgID) === lastMessageId;
165
189
  const isLastIncoming = !isOutgoing && isLastMessage;
166
- const messageId =
167
- message.clientMsgID ||
168
- message.serverMsgID ||
169
- `temp-${message.sendTime || message.createTime}-${index}`;
190
+ const messageId = getMessageRenderId(message, index);
170
191
 
171
192
  const messageData = messageDataMap.get(messageId);
172
193
  if (!messageData) {
173
194
  return null;
174
195
  }
175
196
 
176
- const { dayStart, createdAt } = messageData;
197
+ const { dayStart, timeBreak, createdAt, groupPosition } = messageData;
198
+
199
+ const showSenderGutter = isGroupConversation && !isOutgoing;
200
+ const showName =
201
+ showSenderGutter &&
202
+ (groupPosition === 'first' || groupPosition === 'solo');
203
+ const showAvatar =
204
+ showSenderGutter &&
205
+ (groupPosition === 'last' || groupPosition === 'solo');
177
206
 
178
207
  let flowInputButtonsNodes: GroupChild<'input-buttons'>[] = [];
179
208
  if (
@@ -188,17 +217,20 @@ export const ChatListLegend = memo(
188
217
 
189
218
  return (
190
219
  <>
191
- {dayStart && <LegendChatDay createdAt={createdAt} />}
220
+ {(dayStart || timeBreak) && (
221
+ <LegendChatDay createdAt={createdAt} timeOnly={!dayStart} />
222
+ )}
192
223
  <KContainer.View
193
224
  ref={(node: View | null) => {
194
225
  if (node) rowRefsMap.current.set(messageId, node);
195
226
  else rowRefsMap.current.delete(messageId);
196
227
  }}
197
- style={
228
+ style={[
198
229
  isOutgoing
199
230
  ? messageStyles.messageRowRight
200
- : messageStyles.messageRowLeft
201
- }
231
+ : messageStyles.messageRowLeft,
232
+ { marginBottom: getRowMarginBottom(groupPosition) },
233
+ ]}
202
234
  collapsable={false}
203
235
  >
204
236
  <LegendChatMessage
@@ -215,6 +247,10 @@ export const ChatListLegend = memo(
215
247
  }
216
248
  customMessageItemFactory={customMessageItemFactory}
217
249
  isHighlighted={highlightedId === messageId}
250
+ showName={showName}
251
+ showAvatar={showAvatar}
252
+ showSenderGutter={showSenderGutter}
253
+ groupPosition={groupPosition}
218
254
  />
219
255
  </KContainer.View>
220
256
  {flowInputButtonsNodes && flowInputButtonsNodes.length > 0 && (
@@ -242,6 +278,7 @@ export const ChatListLegend = memo(
242
278
  currentUserId,
243
279
  lastMessageId,
244
280
  messageDataMap,
281
+ isGroupConversation,
245
282
  isBotConversation,
246
283
  onMediaPress,
247
284
  onPressUrl,
@@ -303,12 +340,22 @@ export const ChatListLegend = memo(
303
340
  const getFixedItemSize = useCallback(
304
341
  (item: MessageItem, index: number): number | undefined => {
305
342
  const message = item;
306
- const messageId =
307
- message.clientMsgID ||
308
- message.serverMsgID ||
309
- `temp-${message.sendTime || message.createTime}-${index}`;
343
+ const messageId = getMessageRenderId(message, index);
310
344
 
311
- if (messageDataMap.get(messageId)?.dayStart) return undefined;
345
+ const messageData = messageDataMap.get(messageId);
346
+ // Both separators add chrome above the row that this function does not
347
+ // account for, and a resolved size is never re-measured.
348
+ if (messageData?.dayStart || messageData?.timeBreak) return undefined;
349
+
350
+ // Incoming rows in a group chat carry an avatar column and a sender
351
+ // name whose height this function cannot predict — measure them.
352
+ if (isGroupConversation && message.sendID !== currentUserId) {
353
+ return undefined;
354
+ }
355
+
356
+ const rowMargin = getRowMarginBottom(
357
+ messageData?.groupPosition ?? 'solo'
358
+ );
312
359
 
313
360
  // Resolve the content-type candidate FIRST — for every type other
314
361
  // than these three the result is `undefined` regardless of anything
@@ -319,17 +366,16 @@ export const ChatListLegend = memo(
319
366
  switch (message.contentType) {
320
367
  case MessageType.PictureMessage:
321
368
  candidateSize =
322
- resolveImageDisplayDims(message, windowWidth).height +
323
- ROW_MARGIN_BOTTOM;
369
+ resolveImageDisplayDims(message, windowWidth).height + rowMargin;
324
370
  break;
325
371
  case MessageType.VideoMessage:
326
372
  candidateSize =
327
373
  ChatImageDimens.getDimensions(
328
374
  CHAT_IMAGE_VIEW_SOURCE.MessageListThumbnail
329
- ).height + ROW_MARGIN_BOTTOM;
375
+ ).height + rowMargin;
330
376
  break;
331
377
  case MessageType.StickerMessage:
332
- candidateSize = STICKER_SIZE + ROW_MARGIN_BOTTOM;
378
+ candidateSize = STICKER_SIZE + rowMargin;
333
379
  break;
334
380
  default:
335
381
  return undefined;
@@ -361,6 +407,7 @@ export const ChatListLegend = memo(
361
407
  messageDataMap,
362
408
  customMessageItemFactory,
363
409
  currentUserId,
410
+ isGroupConversation,
364
411
  lastMessageId,
365
412
  isBotConversation,
366
413
  conversationFlow?.flowCurrentStep,
@@ -368,6 +415,28 @@ export const ChatListLegend = memo(
368
415
  ]
369
416
  );
370
417
 
418
+ // LegendList memoises each rendered item on [itemKey, item, extraData], so
419
+ // an item whose own object is unchanged will not re-render. Cluster
420
+ // position depends on a message's NEIGHBOURS, which can change while the
421
+ // message itself does not — prepending older history is enough to turn a
422
+ // 'first' into a 'middle'. messageDataMap is memoised on exactly the inputs
423
+ // that can move those boundaries, so including it here is what keeps a
424
+ // stale tail from being left behind.
425
+ const listExtraData = useMemo(
426
+ () => ({
427
+ messageDataMap,
428
+ flowStepId: conversationFlow?.flowCurrentStep?.id ?? '',
429
+ lastMessageId,
430
+ highlightedId,
431
+ }),
432
+ [
433
+ messageDataMap,
434
+ conversationFlow?.flowCurrentStep?.id,
435
+ lastMessageId,
436
+ highlightedId,
437
+ ]
438
+ );
439
+
371
440
  const handleStartReached = useCallback(() => {
372
441
  if (__DEV__) {
373
442
  console.log('[LegendList] onStartReached triggered', {
@@ -525,7 +594,7 @@ export const ChatListLegend = memo(
525
594
  getFixedItemSize={getFixedItemSize}
526
595
  keyExtractor={(item) => String(item.clientMsgID || item.serverMsgID)}
527
596
  recycleItems={false}
528
- extraData={`${conversationFlow?.flowCurrentStep?.id ?? ''}-${lastMessageId ?? ''}-${highlightedId ?? ''}`}
597
+ extraData={listExtraData}
529
598
  alignItemsAtEnd
530
599
  maintainVisibleContentPosition={maintainVisiblePositionConfig}
531
600
  freeze={freeze}
@@ -46,25 +46,35 @@ const formatDayLabel = (createdAt: number): string | null => {
46
46
 
47
47
  interface LegendChatDayProps {
48
48
  createdAt: number;
49
+ /**
50
+ * Render just the clock time, without the day. Used where a cluster broke on
51
+ * elapsed time inside a single day — the date is already on screen above.
52
+ */
53
+ timeOnly?: boolean;
49
54
  }
50
55
 
51
- export const LegendChatDay = memo(({ createdAt }: LegendChatDayProps) => {
52
- const dateStr = useMemo(
53
- () => (createdAt == null ? null : formatDayLabel(createdAt)),
54
- [createdAt]
55
- );
56
+ export const LegendChatDay = memo(
57
+ ({ createdAt, timeOnly = false }: LegendChatDayProps) => {
58
+ const dateStr = useMemo(() => {
59
+ if (createdAt == null) return null;
60
+ if (!timeOnly) return formatDayLabel(createdAt);
56
61
 
57
- if (!dateStr) return null;
62
+ const date = new Date(createdAt);
63
+ return Number.isNaN(date.getTime()) ? null : formatTime(date);
64
+ }, [createdAt, timeOnly]);
58
65
 
59
- return (
60
- <KContainer.View center marginV="0.5rem">
61
- <KContainer.View>
62
- <KLabel.Text typo="TextXsNormal" color={CHAT_BUBBLE_COLORS.dayLabel}>
63
- {dateStr}
64
- </KLabel.Text>
66
+ if (!dateStr) return null;
67
+
68
+ return (
69
+ <KContainer.View center marginV="0.5rem">
70
+ <KContainer.View>
71
+ <KLabel.Text typo="TextXsNormal" color={CHAT_BUBBLE_COLORS.dayLabel}>
72
+ {dateStr}
73
+ </KLabel.Text>
74
+ </KContainer.View>
65
75
  </KContainer.View>
66
- </KContainer.View>
67
- );
68
- });
76
+ );
77
+ }
78
+ );
69
79
 
70
80
  LegendChatDay.displayName = 'LegendChatDay';
@@ -1,4 +1,10 @@
1
- import { KContainer, KImage, KColors, KSpacingValue } from '@droppii/libs';
1
+ import {
2
+ KContainer,
3
+ KImage,
4
+ KColors,
5
+ KLabel,
6
+ KSpacingValue,
7
+ } from '@droppii/libs';
2
8
  import { StyleSheet } from 'react-native';
3
9
  import { memo, useCallback, useMemo } from 'react';
4
10
  import type { ComponentType, PropsWithChildren, ReactNode } from 'react';
@@ -20,7 +26,10 @@ import type { BaseLegendMessageProps } from '../../../components/messages/types'
20
26
  import { messageStyles } from './messageTypes';
21
27
  import QuotedMessage from '../../../components/messages/quotedMessage';
22
28
  import { StickerMessage } from '../../../components/messages/stickerMessage';
23
- import { GROUP_NOTIFICATION_TEXT } from '../../../utils/messageUtils';
29
+ import { GROUP_NOTIFICATION_TYPES } from '../../../utils/messageUtils';
30
+ import type { GroupPosition } from '../../../utils/legendListMessage';
31
+ import { Avatar } from '../../../components/Avatar';
32
+ import { TAIL_WIDTH } from '../../../components/messages/BubbleTail';
24
33
 
25
34
  type MessageProps = BaseLegendMessageProps & {
26
35
  onPressUrl?: (url: string) => void;
@@ -38,18 +47,20 @@ interface LegendChatMessageProps {
38
47
  onLongPress?: () => void;
39
48
  customMessageItemFactory?: (m: MessageItem) => ReactNode;
40
49
  isHighlighted?: boolean;
50
+ /** Sender name above the bubble — first message of an incoming cluster. */
51
+ showName?: boolean;
52
+ /** Sender avatar beside the bubble — last message of an incoming cluster. */
53
+ showAvatar?: boolean;
54
+ /**
55
+ * Reserve the avatar column. True for every incoming message in a group
56
+ * conversation, not just the one carrying the avatar, so that the middle of
57
+ * a cluster stays aligned with its last message.
58
+ */
59
+ showSenderGutter?: boolean;
60
+ /** Position within its same-sender cluster — drives the bubble tail. */
61
+ groupPosition?: GroupPosition;
41
62
  }
42
63
 
43
- // Notification-style messages (group created/renamed/member changes/etc.)
44
- // are system banners, not user-authored text — they render centered,
45
- // full-width, without a bubble, avatar/status chrome, or left/right
46
- // alignment (see SYSTEM_MESSAGE_TYPES below). Driven by the same lookup
47
- // messageUtils uses to build their preview/thread text, so adding a new
48
- // notification content type there is enough to cover both places.
49
- const GROUP_NOTIFICATION_TYPES = Object.keys(GROUP_NOTIFICATION_TEXT).map(
50
- Number
51
- ) as MessageType[];
52
-
53
64
  const messageComponentMap: Partial<
54
65
  Record<MessageType, ComponentType<MessageProps>>
55
66
  > = {
@@ -88,6 +99,10 @@ export const LegendChatMessage = memo(
88
99
  onLongPress,
89
100
  customMessageItemFactory,
90
101
  isHighlighted,
102
+ showName = false,
103
+ showAvatar = false,
104
+ showSenderGutter = false,
105
+ groupPosition,
91
106
  }: LegendChatMessageProps) => {
92
107
  const handlePress = useCallback(() => {
93
108
  onPress?.(message);
@@ -127,12 +142,34 @@ export const LegendChatMessage = memo(
127
142
 
128
143
  return (
129
144
  <KContainer.View style={messageStyles.wrapper} row alignItems>
145
+ {showSenderGutter && (
146
+ <KContainer.View style={styles.avatarGutter}>
147
+ {showAvatar && (
148
+ <Avatar
149
+ size="sm"
150
+ source={message.senderFaceUrl}
151
+ fullName={message.senderNickname}
152
+ />
153
+ )}
154
+ </KContainer.View>
155
+ )}
130
156
  <MessageStatusIndicator
131
157
  message={message}
132
158
  isOutgoing={isOutgoing}
133
159
  onRetry={onRetry}
134
160
  />
135
161
  <KContainer.View style={styles.content}>
162
+ {showName && !!message.senderNickname && (
163
+ <KLabel.Text
164
+ typo="TextXsNormal"
165
+ color={KColors.gray.normal}
166
+ numberOfLines={1}
167
+ marginB={2}
168
+ style={styles.senderName}
169
+ >
170
+ {message.senderNickname}
171
+ </KLabel.Text>
172
+ )}
136
173
  <LongPressWrapper onPress={handlePress} onLongPress={handleLongPress}>
137
174
  <MessageComponent
138
175
  message={message}
@@ -141,6 +178,7 @@ export const LegendChatMessage = memo(
141
178
  onMediaPress={hasMediaPress ? onMediaPress : undefined}
142
179
  onPressUrl={hasUrlPress ? onPressUrl : undefined}
143
180
  isHighlighted={isHighlighted}
181
+ groupPosition={groupPosition}
144
182
  />
145
183
  </LongPressWrapper>
146
184
 
@@ -161,10 +199,22 @@ export const LegendChatMessage = memo(
161
199
 
162
200
  LegendChatMessage.displayName = 'LegendChatMessage';
163
201
 
202
+ const AVATAR_SIZE = 24;
203
+
164
204
  const styles = StyleSheet.create({
165
205
  content: {
166
206
  position: 'relative',
167
207
  },
208
+ // Bubbles sit behind a TAIL_WIDTH gutter (see BubbleTailRow); the name has to
209
+ // clear the same gutter or it hangs to the left of the bubble it labels.
210
+ senderName: {
211
+ marginLeft: TAIL_WIDTH,
212
+ },
213
+ avatarGutter: {
214
+ width: AVATAR_SIZE,
215
+ marginRight: KSpacingValue['0.25rem'],
216
+ alignSelf: 'flex-end',
217
+ },
168
218
  systemMessageWrapper: {
169
219
  width: '100%',
170
220
  marginVertical: KSpacingValue['0.25rem'],
@@ -49,7 +49,6 @@ export interface ChatDetailHeaderProps {
49
49
  onPressAvatar?: () => void;
50
50
  conversationId: string;
51
51
  targetUserId?: string;
52
- targetGroupId?: string;
53
52
  }
54
53
 
55
54
  export interface ChatQuickActionsRenderParams {
@@ -1,4 +1,4 @@
1
- import { KContainer, KSpacingValue } from '@droppii/libs';
1
+ import { KColors, KContainer, KSpacingValue } from '@droppii/libs';
2
2
  import { memo, useCallback } from 'react';
3
3
  import { ActivityIndicator, StyleSheet } from 'react-native';
4
4
  import type { SearchPublicGroupInfo } from '@droppii/openim-rn-client-sdk';
@@ -41,7 +41,7 @@ export const CommunityTab = memo(({ onPressGroup }: CommunityTabProps) => {
41
41
  <KContainer.Page flex>
42
42
  {isFetching && !isFetchingNextPage && !isRefetching ? (
43
43
  <KContainer.View flex center>
44
- <ActivityIndicator />
44
+ <ActivityIndicator color={KColors.primary.normal} size="small" />
45
45
  </KContainer.View>
46
46
  ) : (
47
47
  <KContainer.FlatList
@@ -39,7 +39,7 @@ export const MessagesTab = memo(({ onPressThread }: MessagesTabProps) => {
39
39
 
40
40
  const LoadingComponent = (
41
41
  <KContainer.View center flex paddingV="3rem">
42
- <ActivityIndicator size="large" color={KColors.palette.primary.w400} />
42
+ <ActivityIndicator color={KColors.primary.normal} size="small" />
43
43
  </KContainer.View>
44
44
  );
45
45
 
@@ -52,23 +52,14 @@ export const useConversationStore = create<ConversationStore>()((set, get) => ({
52
52
  const existing = get().map[id];
53
53
  if (!existing) return;
54
54
 
55
- const merged = { ...existing, ...data };
56
55
  const nextMap = { ...get().map };
57
- if (merged.isNotInGroup) {
58
- delete nextMap[id];
59
- } else {
60
- nextMap[id] = merged;
61
- }
56
+ nextMap[id] = { ...existing, ...data };
62
57
  set(sortConversation(nextMap));
63
58
  },
64
59
  updateConversations(conversations) {
65
60
  const nextMap = conversations.reduce(
66
61
  (pre, curr) => {
67
- if (curr.isNotInGroup) {
68
- delete pre[curr.conversationID];
69
- } else {
70
- pre[curr.conversationID] = curr;
71
- }
62
+ pre[curr.conversationID] = curr;
72
63
  return pre;
73
64
  },
74
65
  { ...get().map }
@@ -86,14 +77,19 @@ export const useConversationStore = create<ConversationStore>()((set, get) => ({
86
77
  },
87
78
  removeGroupConversation(groupID) {
88
79
  const conversationID = getConversationID(SessionType.Group, groupID);
80
+ const existing = get().map[conversationID];
81
+ if (!existing) return;
89
82
 
90
- const newMap = { ...get().map };
91
- delete newMap[conversationID];
92
-
93
- set({
94
- map: newMap,
95
- list: get().list.filter((item) => item !== conversationID),
96
- });
83
+ // Mark rather than delete: the conversation leaves the inbox and loses its
84
+ // pin, but stays addressable so a public group is still readable. Access
85
+ // itself is decided by useGroupAccessGuard, not by the store.
86
+ const nextMap = { ...get().map };
87
+ nextMap[conversationID] = {
88
+ ...existing,
89
+ isNotInGroup: true,
90
+ isPinned: false,
91
+ };
92
+ set(sortConversation(nextMap));
97
93
  },
98
94
  reset() {
99
95
  set({
@@ -209,6 +209,10 @@ const i18nKey: Record<string, string> = {
209
209
  'group:dismiss_confirm_primary': 'Giải tán',
210
210
  'group:dismiss_confirm_secondary': 'Quay lại',
211
211
  'group:dismiss_toast_success': 'Đã giải tán nhóm',
212
+ 'group:access_blocked_title': 'Không thể xem cuộc trò chuyện này',
213
+ 'group:access_blocked_desc':
214
+ 'Bạn hiện không có quyền truy cập vào cuộc trò chuyện hoặc tin nhắn này.',
215
+ 'group:access_blocked_button': 'Đã hiểu',
212
216
  };
213
217
 
214
218
  export default {
@@ -38,9 +38,12 @@ export const getConversationID = (
38
38
  };
39
39
 
40
40
  export const sortConversation = (map: Record<string, ConversationItem>) => {
41
- const list = Object.keys(map).sort((a, b) =>
42
- conversationCompare(map[a]!, map[b]!)
43
- );
41
+ // `map` holds every conversation that can still be opened; `list` is the
42
+ // inbox. A group the user is no longer in stays addressable — a public group
43
+ // remains readable via deeplink or search — but must not show in the inbox.
44
+ const list = Object.keys(map)
45
+ .filter((id) => !map[id]?.isNotInGroup)
46
+ .sort((a, b) => conversationCompare(map[a]!, map[b]!));
44
47
  return { map, list };
45
48
  };
46
49