@droppii-org/chat-mobile 0.2.69 → 0.2.71

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 (52) hide show
  1. package/lib/module/components/GroupItem/index.js +10 -12
  2. package/lib/module/components/GroupItem/index.js.map +1 -1
  3. package/lib/module/components/ThreadCard/ThreadCard.js +2 -2
  4. package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
  5. package/lib/module/hooks/conversation/useGetConversationDetail.js +28 -6
  6. package/lib/module/hooks/conversation/useGetConversationDetail.js.map +1 -1
  7. package/lib/module/hooks/message/useSendMessage.js +8 -2
  8. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  9. package/lib/module/screens/chat-detail/ChatComposer.js +4 -3
  10. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  11. package/lib/module/screens/chat-detail/ChatDetail.js +2 -1
  12. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  13. package/lib/module/screens/chat-detail/ChatDetailHeader.js +9 -3
  14. package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
  15. package/lib/module/screens/chat-detail/ChatListLegend.js +16 -17
  16. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  17. package/lib/module/screens/inbox/Inbox.js.map +1 -1
  18. package/lib/module/screens/inbox/MessagesTab.js.map +1 -1
  19. package/lib/module/translation/resources/i18n.js +3 -1
  20. package/lib/module/translation/resources/i18n.js.map +1 -1
  21. package/lib/typescript/src/components/GroupItem/index.d.ts.map +1 -1
  22. package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts +2 -1
  23. package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
  24. package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts +8 -0
  25. package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts.map +1 -1
  26. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  27. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  28. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  29. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts +1 -1
  30. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts.map +1 -1
  31. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts +1 -1
  32. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
  33. package/lib/typescript/src/screens/chat-detail/types.d.ts +1 -0
  34. package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
  35. package/lib/typescript/src/screens/inbox/Inbox.d.ts +2 -1
  36. package/lib/typescript/src/screens/inbox/Inbox.d.ts.map +1 -1
  37. package/lib/typescript/src/screens/inbox/MessagesTab.d.ts +2 -1
  38. package/lib/typescript/src/screens/inbox/MessagesTab.d.ts.map +1 -1
  39. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  40. package/package.json +1 -1
  41. package/src/components/GroupItem/index.tsx +18 -14
  42. package/src/components/ThreadCard/ThreadCard.tsx +7 -3
  43. package/src/hooks/conversation/useGetConversationDetail.ts +32 -7
  44. package/src/hooks/message/useSendMessage.ts +16 -9
  45. package/src/screens/chat-detail/ChatComposer.tsx +11 -3
  46. package/src/screens/chat-detail/ChatDetail.tsx +1 -0
  47. package/src/screens/chat-detail/ChatDetailHeader.tsx +8 -2
  48. package/src/screens/chat-detail/ChatListLegend.tsx +11 -13
  49. package/src/screens/chat-detail/types.ts +1 -0
  50. package/src/screens/inbox/Inbox.tsx +2 -1
  51. package/src/screens/inbox/MessagesTab.tsx +3 -2
  52. package/src/translation/resources/i18n.ts +2 -0
@@ -6,6 +6,7 @@ import type {
6
6
  MessageItem,
7
7
  OfflinePush,
8
8
  QuoteMsgParams,
9
+ SendMsgParams,
9
10
  } from '@droppii/openim-rn-client-sdk';
10
11
  import {
11
12
  GroupPermission,
@@ -38,15 +39,21 @@ import { useGuardedAction } from '../useGroupPermission';
38
39
 
39
40
  const buildSendParams = (
40
41
  message: MessageItem,
41
- recvID: string,
42
- groupID: string,
43
- extendMessageInfo: IMessageItemEx
44
- ) => ({
45
- groupID,
46
- recvID,
47
- message: { ...message, ex: JSON.stringify(extendMessageInfo) || '{}' },
48
- offlinePushInfo: generateOfflinePushInfo(message),
49
- });
42
+ recvID?: string,
43
+ groupID?: string,
44
+ extendMessageInfo?: IMessageItemEx
45
+ ) =>
46
+ groupID
47
+ ? ({
48
+ groupID,
49
+ message: { ...message, ex: JSON.stringify(extendMessageInfo) || '{}' },
50
+ offlinePushInfo: generateOfflinePushInfo(message),
51
+ } as SendMsgParams)
52
+ : ({
53
+ recvID,
54
+ message: { ...message, ex: JSON.stringify(extendMessageInfo) || '{}' },
55
+ offlinePushInfo: generateOfflinePushInfo(message),
56
+ } as SendMsgParams);
50
57
 
51
58
  export const useSendMessage = () => {
52
59
  const applicationType = useChatContext().applicationType;
@@ -64,7 +64,10 @@ import { useSendMessage } from '../../hooks/message/useSendMessage';
64
64
  import { openBotMenuSheet } from './BotMenuSheet';
65
65
  import { UIUtils } from '../../utils/UIUtils';
66
66
  import { GroupPermission, PeerType } from '@droppii/openim-rn-client-sdk';
67
- import { useGuardedAction } from '../../hooks/useGroupPermission';
67
+ import {
68
+ useGuardedAction,
69
+ useHasGroupPermission,
70
+ } from '../../hooks/useGroupPermission';
68
71
  import { useIsJoinedGroup } from '../../hooks/useIsJoinedGroup';
69
72
 
70
73
  interface ChatComposerInternalProps {
@@ -104,6 +107,9 @@ export const ChatComposer = memo(
104
107
  const { mutateAsync: closeSupportSession } = useCloseSupportSession();
105
108
  const { sendMessage } = useSendMessage();
106
109
  const compose = useChatCompose();
110
+ const isSendMessageAllowed = useHasGroupPermission(
111
+ GroupPermission.SendMessage
112
+ );
107
113
 
108
114
  const { data: isJoinedGroup } = useIsJoinedGroup(conversation?.groupID);
109
115
 
@@ -414,7 +420,7 @@ export const ChatComposer = memo(
414
420
  conversationFlow?.flowCurrentStep?.type === ReactFlowsNodeTypes.Start &&
415
421
  isEmptyMessage;
416
422
 
417
- if (isDisableCompose && !isGroupConversation) {
423
+ if ((isDisableCompose && !isGroupConversation) || !isSendMessageAllowed) {
418
424
  content = (
419
425
  <KContainer.View row alignItems justifyContent>
420
426
  <KContainer.View marginR="0.25rem">
@@ -425,7 +431,9 @@ export const ChatComposer = memo(
425
431
  />
426
432
  </KContainer.View>
427
433
  <KLabel.Text typo="TextXsNormal">
428
- {trans('chat:compose_disabled_seller_inactive')}
434
+ {!isSendMessageAllowed
435
+ ? trans('group:cannot_send_message')
436
+ : trans('chat:compose_disabled_seller_inactive')}
429
437
  </KLabel.Text>
430
438
  </KContainer.View>
431
439
  );
@@ -197,6 +197,7 @@ const ChatDetail = memo(
197
197
  onPressAddMember={onPressAddMember}
198
198
  onPressMenu={handlePressMenu}
199
199
  onPressAvatar={handlePressMenu}
200
+ targetGroupId={targetGroupId}
200
201
  />
201
202
 
202
203
  <PinnedMessageBar
@@ -9,11 +9,11 @@ import {
9
9
  import { AvatarSection } from '../../components/ThreadCard/AvatarSection';
10
10
  import { NamePrefixIcon } from '../../components/ThreadCard/NamePrefixIcon';
11
11
  import type { ChatDetailHeaderProps } from './types';
12
- import { useConversation } from '../../store';
13
12
  import { getConversationSubtitle } from './conversationHeader.utils';
14
13
  import { useGetUsersInfo } from '../../hooks/users/useGetUsersInfo';
15
14
  import { useGetGroupInfo } from '../../hooks/conversation/useGetGroupInfo';
16
15
  import { isGroupConversation } from '../../utils/conversation';
16
+ import { useGetConversationDetail } from '../../hooks/conversation/useGetConversationDetail';
17
17
 
18
18
  const ChatDetailHeader = memo(
19
19
  ({
@@ -25,15 +25,21 @@ const ChatDetailHeader = memo(
25
25
  onPressAddMember,
26
26
  onPressMenu,
27
27
  onPressAvatar,
28
+ targetGroupId,
28
29
  }: ChatDetailHeaderProps) => {
29
- const conversation = useConversation(conversationId);
30
+ const { conversationData: conversation } = useGetConversationDetail({
31
+ targetGroupId,
32
+ targetUserId: targetUserId,
33
+ });
30
34
  const { data: usersInfo } = useGetUsersInfo(
31
35
  targetUserId ? [targetUserId] : []
32
36
  );
37
+
33
38
  const isGroup = isGroupConversation(conversation);
34
39
  const { data: groupInfo } = useGetGroupInfo(
35
40
  isGroup ? conversation?.groupID : undefined
36
41
  );
42
+
37
43
  const { faceURL, showName } = useMemo(() => {
38
44
  const userInfo = usersInfo?.[0];
39
45
  const resolvedFaceURL = conversation?.faceURL || userInfo?.faceURL;
@@ -8,6 +8,7 @@ import {
8
8
  type RefObject,
9
9
  } from 'react';
10
10
  import {
11
+ ActivityIndicator,
11
12
  DeviceEventEmitter,
12
13
  Platform,
13
14
  StyleSheet,
@@ -89,6 +90,7 @@ export const ChatListLegend = memo(
89
90
  freeze,
90
91
  scrollMessageToEnd,
91
92
  keyboardOffset,
93
+ isLoading,
92
94
  }: ChatListLegendInternalProps) => {
93
95
  const currentUserId = useUserStore((s) => s.user?.userID);
94
96
  const windowWidth = useWindowDimensions().width;
@@ -492,16 +494,13 @@ export const ChatListLegend = memo(
492
494
  listRef,
493
495
  ]);
494
496
 
495
- // if (isLoading) {
496
- // return (
497
- // <KContainer.View flex center background={KColors.white}>
498
- // <ActivityIndicator
499
- // color={KColors.palette.primary.w400}
500
- // size="small"
501
- // />
502
- // </KContainer.View>
503
- // );
504
- // }
497
+ if (isLoading) {
498
+ return (
499
+ <KContainer.View flex center background={KColors.white}>
500
+ <ActivityIndicator color={KColors.primary.normal} size="small" />
501
+ </KContainer.View>
502
+ );
503
+ }
505
504
 
506
505
  return (
507
506
  <KContainer.View flex background={KColors.white} style={styles.container}>
@@ -509,7 +508,7 @@ export const ChatListLegend = memo(
509
508
  ref={listRef}
510
509
  data={messages}
511
510
  renderItem={renderItem}
512
- estimatedItemSize={100}
511
+ estimatedItemSize={200}
513
512
  getItemType={getItemType}
514
513
  getFixedItemSize={getFixedItemSize}
515
514
  keyExtractor={(item) => String(item.clientMsgID || item.serverMsgID)}
@@ -517,7 +516,6 @@ export const ChatListLegend = memo(
517
516
  extraData={`${conversationFlow?.flowCurrentStep?.id ?? ''}-${lastMessageId ?? ''}-${highlightedId ?? ''}`}
518
517
  alignItemsAtEnd
519
518
  maintainVisibleContentPosition={maintainVisiblePositionConfig}
520
- maintainScrollAtEnd={true}
521
519
  freeze={freeze}
522
520
  keyboardOffset={keyboardOffset}
523
521
  scrollEventThrottle={16}
@@ -532,7 +530,7 @@ export const ChatListLegend = memo(
532
530
  onEndReached={handleEndReached}
533
531
  onEndReachedThreshold={0.2}
534
532
  showsVerticalScrollIndicator={false}
535
- initialScrollAtEnd
533
+ initialScrollIndex={messages.length - 1}
536
534
  />
537
535
  <Animated.View
538
536
  style={[styles.scrollToBottomButton, animatedButtonStyle]}
@@ -49,6 +49,7 @@ export interface ChatDetailHeaderProps {
49
49
  onPressAvatar?: () => void;
50
50
  conversationId: string;
51
51
  targetUserId?: string;
52
+ targetGroupId?: string;
52
53
  }
53
54
 
54
55
  export interface ChatQuickActionsRenderParams {
@@ -10,11 +10,12 @@ import {
10
10
  KSpacingValue,
11
11
  } from '@droppii/libs';
12
12
  import { MessagesTab } from './MessagesTab';
13
+ import type { ConversationItem } from '@droppii/openim-rn-client-sdk';
13
14
  import { trans } from '../../translation';
14
15
  import { CommunityTab } from './CommunityTab';
15
16
 
16
17
  interface InboxProps {
17
- onPressThread?: (item: string) => void;
18
+ onPressThread?: (item?: ConversationItem) => void;
18
19
  onPressSearch?: () => void;
19
20
  onPressEdit?: () => void;
20
21
  onPressContact?: () => void;
@@ -5,9 +5,10 @@ import { useConversationList } from '../../hooks/useConversationList';
5
5
  import { ThreadCard } from '../../components/ThreadCard';
6
6
  import { useConversationStore } from '../../store';
7
7
  import { useChatContext } from '../../context';
8
+ import type { ConversationItem } from '@droppii/openim-rn-client-sdk';
8
9
 
9
10
  interface MessagesTabProps {
10
- onPressThread?: (item: string) => void;
11
+ onPressThread?: (item?: ConversationItem) => void;
11
12
  }
12
13
 
13
14
  const Separator = () => <KDivider type="line" size="hairline" />;
@@ -23,7 +24,7 @@ export const MessagesTab = memo(({ onPressThread }: MessagesTabProps) => {
23
24
  });
24
25
 
25
26
  const handleThreadPress = useCallback(
26
- (params: { item: string; event: GestureResponderEvent }) => {
27
+ (params: { item?: ConversationItem; event: GestureResponderEvent }) => {
27
28
  onPressThread?.(params.item);
28
29
  },
29
30
  [onPressThread]
@@ -172,6 +172,8 @@ const i18nKey: Record<string, string> = {
172
172
  'group:not_in_group': 'Bạn cần tham gia nhóm để gửi tin nhắn',
173
173
  'group:cannot_send_message': 'Bạn không thể gửi tin nhắn vào nhóm này',
174
174
  'group:joined_group': 'Đã tham gia nhóm {{groupName}}',
175
+ 'group:public_group': 'Nhóm công khai',
176
+ 'group:private_group': 'Nhóm riêng tư',
175
177
  };
176
178
 
177
179
  export default {