@droppii-org/chat-mobile 0.2.65 → 0.2.67

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 (153) hide show
  1. package/lib/module/components/Avatar/Avatar.js +39 -2
  2. package/lib/module/components/Avatar/Avatar.js.map +1 -1
  3. package/lib/module/components/Avatar/DoubleAvatar.js +18 -18
  4. package/lib/module/components/Avatar/DoubleAvatar.js.map +1 -1
  5. package/lib/module/components/Avatar/QuadAvatar.js +131 -0
  6. package/lib/module/components/Avatar/QuadAvatar.js.map +1 -0
  7. package/lib/module/components/Avatar/TripleAvatar.js +97 -0
  8. package/lib/module/components/Avatar/TripleAvatar.js.map +1 -0
  9. package/lib/module/components/Avatar/index.js +2 -0
  10. package/lib/module/components/Avatar/index.js.map +1 -1
  11. package/lib/module/components/ThreadCard/AvatarSection.js +41 -0
  12. package/lib/module/components/ThreadCard/AvatarSection.js.map +1 -1
  13. package/lib/module/components/ThreadCard/NamePrefixIcon.js +5 -4
  14. package/lib/module/components/ThreadCard/NamePrefixIcon.js.map +1 -1
  15. package/lib/module/components/ThreadCard/ThreadCard.js +3 -1
  16. package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
  17. package/lib/module/components/messages/groupNotificationMessage/index.js +25 -0
  18. package/lib/module/components/messages/groupNotificationMessage/index.js.map +1 -0
  19. package/lib/module/context/ChatContext.js +1 -1
  20. package/lib/module/context/ChatContext.js.map +1 -1
  21. package/lib/module/context/ChatDetailContext.js +9 -0
  22. package/lib/module/context/ChatDetailContext.js.map +1 -1
  23. package/lib/module/core/useChatListener.js +120 -21
  24. package/lib/module/core/useChatListener.js.map +1 -1
  25. package/lib/module/hooks/conversation/useGetGroupInfo.js +21 -0
  26. package/lib/module/hooks/conversation/useGetGroupInfo.js.map +1 -0
  27. package/lib/module/hooks/message/useSendMessage.js +6 -3
  28. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  29. package/lib/module/hooks/query-keys.js +2 -1
  30. package/lib/module/hooks/query-keys.js.map +1 -1
  31. package/lib/module/hooks/useConversationList.js +9 -4
  32. package/lib/module/hooks/useConversationList.js.map +1 -1
  33. package/lib/module/screens/ChatInfo/ChatInfo.js +18 -2
  34. package/lib/module/screens/ChatInfo/ChatInfo.js.map +1 -1
  35. package/lib/module/screens/ChatInfo/ChatInfoActions.js +83 -55
  36. package/lib/module/screens/ChatInfo/ChatInfoActions.js.map +1 -1
  37. package/lib/module/screens/ChatInfo/ChatInfoDescriptionRow.js +77 -0
  38. package/lib/module/screens/ChatInfo/ChatInfoDescriptionRow.js.map +1 -0
  39. package/lib/module/screens/ChatInfo/ChatInfoProfile.js +4 -2
  40. package/lib/module/screens/ChatInfo/ChatInfoProfile.js.map +1 -1
  41. package/lib/module/screens/ChatInfo/GroupDescriptionModal.js +58 -0
  42. package/lib/module/screens/ChatInfo/GroupDescriptionModal.js.map +1 -0
  43. package/lib/module/screens/chat-detail/ChatComposer.js +11 -6
  44. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  45. package/lib/module/screens/chat-detail/ChatDetail.js +7 -0
  46. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  47. package/lib/module/screens/chat-detail/ChatDetailHeader.js +10 -3
  48. package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
  49. package/lib/module/screens/chat-detail/conversationHeader.utils.js +13 -3
  50. package/lib/module/screens/chat-detail/conversationHeader.utils.js.map +1 -1
  51. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +29 -2
  52. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
  53. package/lib/module/screens/inbox/MessagesTab.js.map +1 -1
  54. package/lib/module/store/conversation.js +56 -12
  55. package/lib/module/store/conversation.js.map +1 -1
  56. package/lib/module/translation/resources/i18n.js +34 -0
  57. package/lib/module/translation/resources/i18n.js.map +1 -1
  58. package/lib/module/types/events.js +1 -0
  59. package/lib/module/types/events.js.map +1 -1
  60. package/lib/module/utils/conversation.js +3 -0
  61. package/lib/module/utils/conversation.js.map +1 -1
  62. package/lib/module/utils/messageUtils.js +95 -2
  63. package/lib/module/utils/messageUtils.js.map +1 -1
  64. package/lib/typescript/src/components/Avatar/Avatar.d.ts +1 -1
  65. package/lib/typescript/src/components/Avatar/Avatar.d.ts.map +1 -1
  66. package/lib/typescript/src/components/Avatar/Avatar.types.d.ts +5 -1
  67. package/lib/typescript/src/components/Avatar/Avatar.types.d.ts.map +1 -1
  68. package/lib/typescript/src/components/Avatar/DoubleAvatar.d.ts.map +1 -1
  69. package/lib/typescript/src/components/Avatar/QuadAvatar.d.ts +16 -0
  70. package/lib/typescript/src/components/Avatar/QuadAvatar.d.ts.map +1 -0
  71. package/lib/typescript/src/components/Avatar/TripleAvatar.d.ts +15 -0
  72. package/lib/typescript/src/components/Avatar/TripleAvatar.d.ts.map +1 -0
  73. package/lib/typescript/src/components/Avatar/index.d.ts +2 -0
  74. package/lib/typescript/src/components/Avatar/index.d.ts.map +1 -1
  75. package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts +2 -2
  76. package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts.map +1 -1
  77. package/lib/typescript/src/components/ThreadCard/NamePrefixIcon.d.ts +3 -1
  78. package/lib/typescript/src/components/ThreadCard/NamePrefixIcon.d.ts.map +1 -1
  79. package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
  80. package/lib/typescript/src/components/messages/groupNotificationMessage/index.d.ts +3 -0
  81. package/lib/typescript/src/components/messages/groupNotificationMessage/index.d.ts.map +1 -0
  82. package/lib/typescript/src/context/ChatDetailContext.d.ts +2 -0
  83. package/lib/typescript/src/context/ChatDetailContext.d.ts.map +1 -1
  84. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  85. package/lib/typescript/src/hooks/conversation/useGetGroupInfo.d.ts +2 -0
  86. package/lib/typescript/src/hooks/conversation/useGetGroupInfo.d.ts.map +1 -0
  87. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  88. package/lib/typescript/src/hooks/query-keys.d.ts +1 -0
  89. package/lib/typescript/src/hooks/query-keys.d.ts.map +1 -1
  90. package/lib/typescript/src/hooks/useConversationList.d.ts.map +1 -1
  91. package/lib/typescript/src/screens/ChatInfo/ChatInfo.d.ts +1 -1
  92. package/lib/typescript/src/screens/ChatInfo/ChatInfo.d.ts.map +1 -1
  93. package/lib/typescript/src/screens/ChatInfo/ChatInfoActions.d.ts +3 -1
  94. package/lib/typescript/src/screens/ChatInfo/ChatInfoActions.d.ts.map +1 -1
  95. package/lib/typescript/src/screens/ChatInfo/ChatInfoDescriptionRow.d.ts +7 -0
  96. package/lib/typescript/src/screens/ChatInfo/ChatInfoDescriptionRow.d.ts.map +1 -0
  97. package/lib/typescript/src/screens/ChatInfo/ChatInfoProfile.d.ts.map +1 -1
  98. package/lib/typescript/src/screens/ChatInfo/GroupDescriptionModal.d.ts +9 -0
  99. package/lib/typescript/src/screens/ChatInfo/GroupDescriptionModal.d.ts.map +1 -0
  100. package/lib/typescript/src/screens/ChatInfo/types.d.ts +1 -0
  101. package/lib/typescript/src/screens/ChatInfo/types.d.ts.map +1 -1
  102. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  103. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  104. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts.map +1 -1
  105. package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts +1 -1
  106. package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts.map +1 -1
  107. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
  108. package/lib/typescript/src/screens/inbox/MessagesTab.d.ts.map +1 -1
  109. package/lib/typescript/src/store/conversation.d.ts +11 -0
  110. package/lib/typescript/src/store/conversation.d.ts.map +1 -1
  111. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  112. package/lib/typescript/src/types/events.d.ts +6 -1
  113. package/lib/typescript/src/types/events.d.ts.map +1 -1
  114. package/lib/typescript/src/utils/conversation.d.ts +1 -0
  115. package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
  116. package/lib/typescript/src/utils/messageUtils.d.ts +6 -1
  117. package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
  118. package/package.json +2 -2
  119. package/src/build-ignore.d.ts +1 -0
  120. package/src/components/Avatar/Avatar.tsx +47 -0
  121. package/src/components/Avatar/Avatar.types.ts +5 -1
  122. package/src/components/Avatar/DoubleAvatar.tsx +16 -13
  123. package/src/components/Avatar/QuadAvatar.tsx +161 -0
  124. package/src/components/Avatar/TripleAvatar.tsx +119 -0
  125. package/src/components/Avatar/index.ts +2 -0
  126. package/src/components/ThreadCard/AvatarSection.tsx +58 -2
  127. package/src/components/ThreadCard/NamePrefixIcon.tsx +32 -25
  128. package/src/components/ThreadCard/ThreadCard.tsx +2 -0
  129. package/src/components/messages/groupNotificationMessage/index.tsx +28 -0
  130. package/src/context/ChatContext.tsx +1 -1
  131. package/src/context/ChatDetailContext.tsx +15 -0
  132. package/src/core/useChatListener.ts +175 -23
  133. package/src/hooks/conversation/useGetGroupInfo.ts +20 -0
  134. package/src/hooks/message/useSendMessage.ts +11 -3
  135. package/src/hooks/query-keys.ts +1 -0
  136. package/src/hooks/useConversationList.ts +17 -7
  137. package/src/screens/ChatInfo/ChatInfo.tsx +16 -0
  138. package/src/screens/ChatInfo/ChatInfoActions.tsx +68 -35
  139. package/src/screens/ChatInfo/ChatInfoDescriptionRow.tsx +102 -0
  140. package/src/screens/ChatInfo/ChatInfoProfile.tsx +6 -3
  141. package/src/screens/ChatInfo/GroupDescriptionModal.tsx +67 -0
  142. package/src/screens/ChatInfo/types.ts +1 -0
  143. package/src/screens/chat-detail/ChatComposer.tsx +19 -10
  144. package/src/screens/chat-detail/ChatDetail.tsx +12 -1
  145. package/src/screens/chat-detail/ChatDetailHeader.tsx +19 -3
  146. package/src/screens/chat-detail/conversationHeader.utils.ts +14 -6
  147. package/src/screens/chat-detail/legend/LegendChatMessage.tsx +36 -1
  148. package/src/screens/inbox/MessagesTab.tsx +0 -1
  149. package/src/store/conversation.ts +62 -17
  150. package/src/translation/resources/i18n.ts +34 -0
  151. package/src/types/events.ts +6 -0
  152. package/src/utils/conversation.ts +6 -0
  153. package/src/utils/messageUtils.ts +103 -1
@@ -1,6 +1,6 @@
1
1
  import { memo } from 'react';
2
2
  import { Image, StyleSheet } from 'react-native';
3
- import { KContainer, KImage, KColors } from '@droppii/libs';
3
+ import { KContainer, KImage, KColors, type KSpacing } from '@droppii/libs';
4
4
  import Images from '../../assets/images';
5
5
  import { PeerType } from '@droppii/openim-rn-client-sdk';
6
6
 
@@ -13,34 +13,41 @@ const styles = StyleSheet.create({
13
13
 
14
14
  interface NamePrefixIconProps {
15
15
  peerType?: PeerType | string;
16
+ marginR?: KSpacing;
16
17
  }
17
18
 
18
- export const NamePrefixIcon = memo(({ peerType }: NamePrefixIconProps) => {
19
- if (peerType === PeerType.Bot) {
20
- return (
21
- <KContainer.View marginR="0.25rem">
22
- <Image source={Images.ICON_DROPPII} style={styles.icon} />
23
- </KContainer.View>
24
- );
25
- }
19
+ export const NamePrefixIcon = memo(
20
+ ({ peerType, marginR = '0.25rem' }: NamePrefixIconProps) => {
21
+ if (peerType === PeerType.Bot) {
22
+ return (
23
+ <KContainer.View marginR={marginR}>
24
+ <Image source={Images.ICON_DROPPII} style={styles.icon} />
25
+ </KContainer.View>
26
+ );
27
+ }
26
28
 
27
- if (peerType === PeerType.Group) {
28
- return (
29
- <KContainer.View marginR="0.25rem">
30
- <KImage.VectorIcons name="user-two-b" size={14} color={KColors.black} />
31
- </KContainer.View>
32
- );
33
- }
29
+ if (peerType === PeerType.Group) {
30
+ return (
31
+ <KContainer.View marginR={marginR}>
32
+ <KImage.VectorIcons
33
+ name="user-two-b"
34
+ size={14}
35
+ color={KColors.black}
36
+ />
37
+ </KContainer.View>
38
+ );
39
+ }
34
40
 
35
- // if (peerType === DChatPeerType.CUSTOMER) {
36
- // return (
37
- // <KContainer.View marginR="0.25rem">
38
- // <Image source={Images.ICON_DROPPII} style={styles.icon} />
39
- // </KContainer.View>
40
- // );
41
- // }
41
+ // if (peerType === DChatPeerType.CUSTOMER) {
42
+ // return (
43
+ // <KContainer.View marginR={marginR}>
44
+ // <Image source={Images.ICON_DROPPII} style={styles.icon} />
45
+ // </KContainer.View>
46
+ // );
47
+ // }
42
48
 
43
- return null;
44
- });
49
+ return null;
50
+ }
51
+ );
45
52
 
46
53
  NamePrefixIcon.displayName = 'NamePrefixIcon';
@@ -33,6 +33,7 @@ const ThreadCard = memo(({ item, onPress }: ThreadCardProps) => {
33
33
  peerType,
34
34
  showName,
35
35
  faceURL,
36
+ members,
36
37
  unreadCount = 0,
37
38
  recvMsgOpt = MessageReceiveOptType.Normal,
38
39
  isPinned,
@@ -120,6 +121,7 @@ const ThreadCard = memo(({ item, onPress }: ThreadCardProps) => {
120
121
  avatar={faceURL ?? null}
121
122
  fullName={fullName}
122
123
  peerType={peerType}
124
+ members={members}
123
125
  />
124
126
 
125
127
  {/* Chat-Content */}
@@ -0,0 +1,28 @@
1
+ import { memo } from 'react';
2
+ import { KLabel } from '@droppii/libs';
3
+ import { trans } from '../../../translation';
4
+ import { CHAT_BUBBLE_COLORS } from '../../../screens/chat-detail/constants';
5
+ import {
6
+ GROUP_NOTIFICATION_TEXT,
7
+ getNotificationOpUserNickname,
8
+ } from '../../../utils/messageUtils';
9
+ import type { BaseLegendMessageProps } from '../types';
10
+
11
+ export const GroupNotificationMessage = memo(
12
+ ({ message, isOutgoing }: BaseLegendMessageProps) => {
13
+ const notification = GROUP_NOTIFICATION_TEXT[message.contentType];
14
+ if (!notification) return null;
15
+
16
+ const sender = isOutgoing
17
+ ? 'Bạn'
18
+ : message.senderNickname || getNotificationOpUserNickname(message) || '';
19
+
20
+ return (
21
+ <KLabel.Text typo="TextXsNormal" color={CHAT_BUBBLE_COLORS.dayLabel}>
22
+ {trans(notification.bySenderKey, { sender })}
23
+ </KLabel.Text>
24
+ );
25
+ }
26
+ );
27
+
28
+ GroupNotificationMessage.displayName = 'GroupNotificationMessage';
@@ -130,7 +130,7 @@ const ChatSdkBridge = () => {
130
130
  };
131
131
 
132
132
  export const ChatProvider = ({ ...props }: ChatProviderProps) => {
133
- const { enabled = false } = props;
133
+ const { enabled = true } = props;
134
134
 
135
135
  if (!enabled) {
136
136
  return props.children;
@@ -5,6 +5,7 @@ import {
5
5
  useEffect,
6
6
  useMemo,
7
7
  useState,
8
+ type ComponentType,
8
9
  } from 'react';
9
10
  import { DeviceEventEmitter } from 'react-native';
10
11
  import {
@@ -189,3 +190,17 @@ export const ChatDetailProvider = ({ children }: ChatDetailProviderProps) => {
189
190
  </ChatDetailContext.Provider>
190
191
  );
191
192
  };
193
+
194
+ export function withChatDetailProvider<P extends object>(
195
+ Component: ComponentType<P>
196
+ ): ComponentType<P> {
197
+ const WithChatDetailProvider = (props: P) => (
198
+ <ChatDetailProvider>
199
+ <Component {...props} />
200
+ </ChatDetailProvider>
201
+ );
202
+ WithChatDetailProvider.displayName = `withChatDetailProvider(${
203
+ Component.displayName || Component.name || 'Component'
204
+ })`;
205
+ return WithChatDetailProvider;
206
+ }
@@ -2,12 +2,15 @@ import OpenIMSDK, {
2
2
  MessageReceiveOptType,
3
3
  MessageType,
4
4
  OpenIMEvent,
5
+ SessionType,
5
6
  type ConversationItem,
7
+ type GroupItem,
6
8
  type GroupMemberItem,
7
9
  type MessageItem,
8
10
  type MessagePinned,
9
11
  type RevokedInfo,
10
12
  } from '@droppii/openim-rn-client-sdk';
13
+ import { useQueryClient } from '@tanstack/react-query';
11
14
  import { useCallback, useEffect } from 'react';
12
15
  import { useConversationStore } from '../store/conversation';
13
16
  import { ToastFlashMessage } from '../utils/toastFlashMessage';
@@ -18,22 +21,31 @@ import isEmpty from 'lodash/isEmpty';
18
21
  import { markMessageRevoked, useMessageStore } from '../store/message';
19
22
  import { syncPinnedMessagesOnEvent } from '../hooks/message/usePinMessage';
20
23
  import { belongsToConversation } from '../utils/message';
24
+ import { getConversationID } from '../utils/conversation';
21
25
  import { DeviceEventEmitter } from 'react-native';
22
26
  import { ChatEvent } from '../types/events';
27
+ import { conversationQueryKeys } from '../hooks/query-keys';
23
28
 
24
29
  export const useChatListener = () => {
25
30
  const updateOneMessage = useMessageStore((state) => state.updateOneMessage);
26
31
  const currentUserId = useUserStore((s) => s.user?.userID);
27
32
  const onPressFlashMessage = useChatContext()?.onPressFlashMessage;
28
33
  const isShowFLashMessage = useChatContext()?.isShowFLashMessage;
34
+ const queryClient = useQueryClient();
29
35
 
30
36
  const onSendMessageProgress = useCallback(
31
- ({ progress, message }: { progress: number; message: MessageItem }) => {
32
- console.log('[Listener] SendMessageProgress', {
33
- clientMsgID: message.clientMsgID,
34
- status: message.status,
35
- progress,
36
- });
37
+ ({
38
+ progress: _progress,
39
+ message,
40
+ }: {
41
+ progress: number;
42
+ message: MessageItem;
43
+ }) => {
44
+ // console.log('[Listener] SendMessageProgress', {
45
+ // clientMsgID: message.clientMsgID,
46
+ // status: message.status,
47
+ // progress,
48
+ // });
37
49
  updateOneMessage(message);
38
50
  },
39
51
  [updateOneMessage]
@@ -41,6 +53,7 @@ export const useChatListener = () => {
41
53
 
42
54
  const onConversationChanged = useCallback(
43
55
  (conversations: ConversationItem[]) => {
56
+ // console.log('[Listener] OnConversationChanged', conversations);
44
57
  const oldMap = useConversationStore.getState().map;
45
58
  const visibleConversations: ConversationItem[] = [];
46
59
 
@@ -87,26 +100,156 @@ export const useChatListener = () => {
87
100
  );
88
101
 
89
102
  const onNewConversation = useCallback((conversations: ConversationItem[]) => {
90
- console.log('[Listener] OnNewConversation', conversations);
103
+ // console.log(
104
+ // '[Listener] OnNewConversation',
105
+ // conversations.map((c) => ({
106
+ // conversationID: c.conversationID,
107
+ // groupID: c.groupID,
108
+ // isNotInGroup: c.isNotInGroup,
109
+ // isGuardedRemoved: c.groupID
110
+ // ? useConversationStore.getState().removedGroupIds.has(c.groupID)
111
+ // : false,
112
+ // }))
113
+ // );
91
114
  useConversationStore.getState().updateConversations(conversations);
92
115
  }, []);
93
116
 
94
- const onGroupMemberAdded = useCallback((member: GroupMemberItem) => {
95
- console.log('[Listener] OnGroupMemberAdded', {
96
- userID: member.userID,
97
- groupID: member.groupID,
98
- });
99
- }, []);
117
+ const onGroupInfoChanged = useCallback(
118
+ (group: GroupItem) => {
119
+ // console.log('[Listener] OnGroupInfoChanged', {
120
+ // groupID: group.groupID,
121
+ // memberCount: group.memberCount,
122
+ // });
123
+ queryClient.setQueryData(
124
+ conversationQueryKeys.groupInfo(group.groupID),
125
+ group
126
+ );
127
+ },
128
+ [queryClient]
129
+ );
100
130
 
101
- const onGroupMemberDeleted = useCallback((member: GroupMemberItem) => {
102
- console.log('[Listener] OnGroupMemberDeleted', {
103
- userID: member.userID,
104
- groupID: member.groupID,
105
- });
106
- }, []);
131
+ const onGroupMemberAdded = useCallback(
132
+ (member: GroupMemberItem) => {
133
+ // console.log('[Listener] OnGroupMemberAdded', {
134
+ // userID: member.userID,
135
+ // groupID: member.groupID,
136
+ // isCurrentUser: member.userID === currentUserId,
137
+ // });
138
+ queryClient.invalidateQueries({
139
+ queryKey: conversationQueryKeys.groupInfo(member.groupID),
140
+ });
141
+
142
+ // The current user (re)joined this group — lift the removal guard so
143
+ // a future OnConversationChanged/OnNewConversation for it isn't dropped.
144
+ if (member.userID === currentUserId) {
145
+ useConversationStore
146
+ .getState()
147
+ .restoreGroupConversation(member.groupID);
148
+ }
149
+ },
150
+ [queryClient, currentUserId]
151
+ );
152
+
153
+ const removeGroupConversation = useCallback(
154
+ (
155
+ groupID: string,
156
+ groupName: string | undefined,
157
+ reason: 'left' | 'dismissed' | 'kicked'
158
+ ) => {
159
+ // console.log('[Listener] removeGroupConversation', { groupID, reason });
160
+
161
+ // TEMPORARILY DISABLED: OnConversationChanged/OnNewConversation can
162
+ // still race this removal and resurrect the conversation before the
163
+ // removedGroupIds guard is proven reliable. Flip this back to `true`
164
+ // once that race is confirmed fixed.
165
+ const REMOVE_FLOW_ENABLED: boolean = false;
166
+ if (!REMOVE_FLOW_ENABLED) return;
167
+
168
+ const conversationID = getConversationID(SessionType.Group, groupID);
169
+ const conversation = useConversationStore.getState().map[conversationID];
170
+ const isCurrentConversation =
171
+ useConversationStore.getState().currentConversationId ===
172
+ conversationID;
173
+
174
+ // Marks groupID as removed so any late-arriving conversation-sync event
175
+ // for it (see onConversationChanged/onNewConversation) is dropped
176
+ // instead of silently resurrecting the conversation we just removed.
177
+ useConversationStore.getState().removeGroupConversation(groupID);
178
+
179
+ queryClient.removeQueries({
180
+ queryKey: conversationQueryKeys.groupInfo(groupID),
181
+ });
182
+
183
+ ToastFlashMessage.show({
184
+ key: `group-removed-${groupID}`,
185
+ title: groupName || conversation?.showName || 'Nhóm',
186
+ body:
187
+ reason === 'dismissed'
188
+ ? 'Nhóm đã bị giải tán'
189
+ : reason === 'kicked'
190
+ ? 'Bạn đã bị mời khỏi nhóm'
191
+ : 'Bạn không còn trong nhóm này',
192
+ });
193
+
194
+ if (isCurrentConversation) {
195
+ DeviceEventEmitter.emit(ChatEvent.GroupRemoved, {
196
+ groupID,
197
+ reason,
198
+ });
199
+ }
200
+ },
201
+ [queryClient]
202
+ );
203
+
204
+ const onGroupMemberDeleted = useCallback(
205
+ (member: GroupMemberItem) => {
206
+ // console.log('[Listener] OnGroupMemberDeleted', {
207
+ // userID: member.userID,
208
+ // groupID: member.groupID,
209
+ // isCurrentUser: member.userID === currentUserId,
210
+ // });
211
+ queryClient.invalidateQueries({
212
+ queryKey: conversationQueryKeys.groupInfo(member.groupID),
213
+ });
214
+
215
+ // The removed member is the current user themselves — they were kicked,
216
+ // so their conversation for this group must be dropped like a leave/dismiss.
217
+ if (member.userID === currentUserId) {
218
+ removeGroupConversation(member.groupID, undefined, 'kicked');
219
+ }
220
+ },
221
+ [queryClient, currentUserId, removeGroupConversation]
222
+ );
223
+
224
+ const onJoinedGroupDeleted = useCallback(
225
+ (group: GroupItem) => {
226
+ // console.log('[Listener] OnJoinedGroupDeleted', {
227
+ // groupID: group.groupID,
228
+ // groupName: group.groupName,
229
+ // });
230
+ removeGroupConversation(group.groupID, group.groupName, 'left');
231
+ },
232
+ [removeGroupConversation]
233
+ );
234
+
235
+ const onGroupDismissed = useCallback(
236
+ (group: GroupItem) => {
237
+ // console.log('[Listener] OnGroupDismissed', {
238
+ // groupID: group.groupID,
239
+ // groupName: group.groupName,
240
+ // });
241
+ removeGroupConversation(group.groupID, group.groupName, 'dismissed');
242
+ },
243
+ [removeGroupConversation]
244
+ );
107
245
 
108
246
  const OnGroupMemberInfoChanged = useCallback(
109
247
  (member: GroupMemberItem) => {
248
+ // console.log('[Listener] OnGroupMemberInfoChanged', {
249
+ // userID: member.userID,
250
+ // groupID: member.groupID,
251
+ // permissions: member.permissions,
252
+ // });
110
253
  const conversation = useConversationStore
111
254
  .getState()
112
255
  .getCurrentConversation();
@@ -148,7 +291,7 @@ export const useChatListener = () => {
148
291
  );
149
292
 
150
293
  const onRecvNewMessages = useCallback((messages: MessageItem[]) => {
151
- console.log('[Listener] OnRecvNewMessages', messages);
294
+ // console.log('[Listener] OnRecvNewMessages', messages);
152
295
  const conversationId =
153
296
  useConversationStore.getState().currentConversationId;
154
297
  const targetUserId = useConversationStore.getState().currentUserId;
@@ -164,8 +307,8 @@ export const useChatListener = () => {
164
307
  relevant.forEach((msg) => useMessageStore.getState().pushNewMessage(msg));
165
308
  }, []);
166
309
 
167
- const onRecvOfflineNewMessages = useCallback((messages: MessageItem[]) => {
168
- console.log('[Listener] onRecvOfflineNewMessages', messages);
310
+ const onRecvOfflineNewMessages = useCallback((_messages: MessageItem[]) => {
311
+ // console.log('[Listener] onRecvOfflineNewMessages', _messages);
169
312
  }, []);
170
313
 
171
314
  useEffect(() => {
@@ -174,12 +317,15 @@ export const useChatListener = () => {
174
317
  OpenIMSDK.on(OpenIMEvent.OnNewConversation, onNewConversation);
175
318
 
176
319
  // Group members
320
+ OpenIMSDK.on(OpenIMEvent.OnGroupInfoChanged, onGroupInfoChanged);
177
321
  OpenIMSDK.on(OpenIMEvent.OnGroupMemberAdded, onGroupMemberAdded);
178
322
  OpenIMSDK.on(OpenIMEvent.OnGroupMemberDeleted, onGroupMemberDeleted);
179
323
  OpenIMSDK.on(
180
324
  OpenIMEvent.OnGroupMemberInfoChanged,
181
325
  OnGroupMemberInfoChanged
182
326
  );
327
+ OpenIMSDK.on(OpenIMEvent.OnJoinedGroupDeleted, onJoinedGroupDeleted);
328
+ OpenIMSDK.on(OpenIMEvent.OnGroupDismissed, onGroupDismissed);
183
329
 
184
330
  // Message status
185
331
  OpenIMSDK.on(OpenIMEvent.SendMessageProgress, onSendMessageProgress);
@@ -197,12 +343,15 @@ export const useChatListener = () => {
197
343
  OpenIMSDK.off(OpenIMEvent.OnNewConversation, onNewConversation);
198
344
 
199
345
  // Group members
346
+ OpenIMSDK.off(OpenIMEvent.OnGroupInfoChanged, onGroupInfoChanged);
200
347
  OpenIMSDK.off(OpenIMEvent.OnGroupMemberAdded, onGroupMemberAdded);
201
348
  OpenIMSDK.off(OpenIMEvent.OnGroupMemberDeleted, onGroupMemberDeleted);
202
- OpenIMSDK.on(
349
+ OpenIMSDK.off(
203
350
  OpenIMEvent.OnGroupMemberInfoChanged,
204
351
  OnGroupMemberInfoChanged
205
352
  );
353
+ OpenIMSDK.off(OpenIMEvent.OnJoinedGroupDeleted, onJoinedGroupDeleted);
354
+ OpenIMSDK.off(OpenIMEvent.OnGroupDismissed, onGroupDismissed);
206
355
 
207
356
  // Message status
208
357
  OpenIMSDK.off(OpenIMEvent.SendMessageProgress, onSendMessageProgress);
@@ -216,6 +365,7 @@ export const useChatListener = () => {
216
365
  };
217
366
  }, [
218
367
  onConversationChanged,
368
+ onGroupInfoChanged,
219
369
  onGroupMemberAdded,
220
370
  onGroupMemberDeleted,
221
371
  onMessagePinned,
@@ -225,5 +375,7 @@ export const useChatListener = () => {
225
375
  onRecvNewMessages,
226
376
  onRecvOfflineNewMessages,
227
377
  OnGroupMemberInfoChanged,
378
+ onJoinedGroupDeleted,
379
+ onGroupDismissed,
228
380
  ]);
229
381
  };
@@ -0,0 +1,20 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import OpenIMSDK from '@droppii/openim-rn-client-sdk';
3
+ import { conversationQueryKeys } from '../query-keys';
4
+
5
+ export const useGetGroupInfo = (groupId = '') =>
6
+ useQuery({
7
+ queryKey: conversationQueryKeys.groupInfo(groupId),
8
+ queryFn: async () => {
9
+ try {
10
+ const res = await OpenIMSDK.getSpecifiedGroupsInfo([groupId]);
11
+ return res?.[0];
12
+ } catch (error) {
13
+ console.error('useGetGroupInfo error:', error);
14
+ return null;
15
+ }
16
+ },
17
+ enabled: !!groupId,
18
+ staleTime: 0,
19
+ refetchOnMount: 'always',
20
+ });
@@ -268,14 +268,22 @@ export const generateOfflinePushInfo = (message: MessageItem) => {
268
268
  const conversationData = useConversationStore
269
269
  ?.getState?.()
270
270
  ?.getCurrentConversation();
271
- const operatorUserID = useUserStore.getState().user?.userID || '';
272
- const title = conversationData?.showName || 'Droppii';
271
+ const operator = useUserStore.getState().user;
272
+ const operatorUserID = operator?.userID || '';
273
+ const isSingleChat =
274
+ conversationData?.conversationType === SessionType.Single;
275
+ const title = isSingleChat
276
+ ? operator?.nickname || 'Droppii'
277
+ : conversationData?.showName || 'Droppii';
278
+ const icon = isSingleChat
279
+ ? operator?.faceURL || ''
280
+ : conversationData?.faceURL || '';
273
281
  const desc = getMessagePreview(message);
274
282
  return {
275
283
  title,
276
284
  desc,
277
285
  ex: JSON.stringify({
278
- icon: conversationData?.faceURL || '',
286
+ icon,
279
287
  conversationId: conversationData?.conversationID || '',
280
288
  userId: operatorUserID,
281
289
  groupId: conversationData?.groupID || '',
@@ -32,6 +32,7 @@ export const conversationQueryKeys = {
32
32
  detailBySourceId: (sourceId: string) => ['detailBySourceId', sourceId],
33
33
  joinedGroup: (groupId?: string) => [...conversationQueryKeys.all, groupId],
34
34
  create: (userId?: string) => ['create', userId],
35
+ groupInfo: (groupId: string) => ['groupInfo', groupId] as const,
35
36
  };
36
37
 
37
38
  export const usersQueryKeys = {
@@ -25,14 +25,24 @@ export function useConversationList({
25
25
  enabled: enabled !== false,
26
26
  queryFn: async () => {
27
27
  const offset = (page - 1) * 500;
28
- const conversations = await OpenIMSDK.getConversationListSplitApp({
29
- offset,
30
- count: 500,
31
- applicationType,
32
- });
28
+ const [conversations, joinedGroups] = await Promise.all([
29
+ OpenIMSDK.getConversationListSplitApp({
30
+ offset,
31
+ count: 500,
32
+ applicationType,
33
+ }),
34
+ OpenIMSDK.getJoinedGroupList(),
35
+ ]);
33
36
 
34
- useConversationStore.getState().updateConversations(conversations);
35
- return conversations;
37
+ const joinedGroupIds = new Set(joinedGroups.map((g) => g.groupID));
38
+ const resolved = conversations.map((conversation) =>
39
+ conversation.groupID && !joinedGroupIds.has(conversation.groupID)
40
+ ? { ...conversation, isNotInGroup: true }
41
+ : conversation
42
+ );
43
+
44
+ useConversationStore.getState().updateConversations(resolved);
45
+ return resolved;
36
46
  },
37
47
  });
38
48
 
@@ -2,12 +2,15 @@ import { memo } from 'react';
2
2
  import { KContainer, KNavigation } from '@droppii/libs';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { useGetConversationTarget } from '../../hooks/conversation/useGetConversationDetail';
5
+ import { useGetGroupInfo } from '../../hooks/conversation/useGetGroupInfo';
5
6
  import { useConversation } from '../../store';
6
7
  import ChatInfoProfile from './ChatInfoProfile';
7
8
  import ChatInfoMediaRow from './ChatInfoMediaRow';
9
+ import ChatInfoDescriptionRow from './ChatInfoDescriptionRow';
8
10
  import ChatInfoActions from './ChatInfoActions';
9
11
  import type { ChatInfoProps } from './types';
10
12
  import { trans } from '../../translation';
13
+ import { isGroupConversation } from '../../utils/conversation';
11
14
 
12
15
  const ChatInfo = memo(
13
16
  ({
@@ -18,12 +21,17 @@ const ChatInfo = memo(
18
21
  onPressOrders,
19
22
  onPressCreateGroup,
20
23
  onPressAddToGroup,
24
+ onPressLeaveGroup,
21
25
  }: ChatInfoProps) => {
22
26
  const navigation = useNavigation();
23
27
 
24
28
  const conversation = useConversation(conversationId);
25
29
  const { data: target } = useGetConversationTarget(conversationId);
26
30
  const isTargetActive = target ? target.isActive : true;
31
+ const isGroup = isGroupConversation(conversation);
32
+ const { data: groupInfo } = useGetGroupInfo(
33
+ isGroup ? conversation?.groupID : undefined
34
+ );
27
35
 
28
36
  return (
29
37
  <KContainer.Page flex edges={['bottom']} background="#EBEDF2">
@@ -45,12 +53,20 @@ const ChatInfo = memo(
45
53
  onPressSearch={onPressSearch}
46
54
  />
47
55
  <ChatInfoMediaRow onPressMedia={onPressMedia} />
56
+ <KContainer.VisibleView visible={isGroup}>
57
+ <ChatInfoDescriptionRow
58
+ introduction={groupInfo?.introduction}
59
+ groupName={conversation?.showName}
60
+ />
61
+ </KContainer.VisibleView>
48
62
  <ChatInfoActions
49
63
  conversation={conversation}
50
64
  isTargetActive={isTargetActive}
65
+ isGroup={isGroup}
51
66
  onPressOrders={onPressOrders}
52
67
  onPressCreateGroup={onPressCreateGroup}
53
68
  onPressAddToGroup={onPressAddToGroup}
69
+ onPressLeaveGroup={onPressLeaveGroup}
54
70
  />
55
71
  </KContainer.ScrollView>
56
72
  </KContainer.Page>