@droppii-org/chat-mobile 0.2.39 → 0.2.41

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 (49) hide show
  1. package/lib/module/core/useChatListener.js +3 -10
  2. package/lib/module/core/useChatListener.js.map +1 -1
  3. package/lib/module/hooks/message/useSendMessage.js +0 -3
  4. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  5. package/lib/module/screens/chat-detail/PinnedMessageBar.js +4 -1
  6. package/lib/module/screens/chat-detail/PinnedMessageBar.js.map +1 -1
  7. package/lib/module/screens/chat-detail/PinnedMessagesSheet.js +80 -110
  8. package/lib/module/screens/chat-detail/PinnedMessagesSheet.js.map +1 -1
  9. package/lib/module/screens/chat-detail/PinnedMessagesSheetBackup.js +179 -0
  10. package/lib/module/screens/chat-detail/PinnedMessagesSheetBackup.js.map +1 -0
  11. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +18 -6
  12. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
  13. package/lib/module/store/message.js +33 -0
  14. package/lib/module/store/message.js.map +1 -1
  15. package/lib/module/translation/resources/i18n.js +3 -2
  16. package/lib/module/translation/resources/i18n.js.map +1 -1
  17. package/lib/module/utils/UIUtils.js +4 -2
  18. package/lib/module/utils/UIUtils.js.map +1 -1
  19. package/lib/module/utils/toastFlashMessage.js +4 -1
  20. package/lib/module/utils/toastFlashMessage.js.map +1 -1
  21. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  22. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  23. package/lib/typescript/src/screens/chat-detail/PinnedMessageBar.d.ts +1 -1
  24. package/lib/typescript/src/screens/chat-detail/PinnedMessageBar.d.ts.map +1 -1
  25. package/lib/typescript/src/screens/chat-detail/PinnedMessagesSheet.d.ts +1 -1
  26. package/lib/typescript/src/screens/chat-detail/PinnedMessagesSheet.d.ts.map +1 -1
  27. package/lib/typescript/src/screens/chat-detail/PinnedMessagesSheetBackup.d.ts +9 -0
  28. package/lib/typescript/src/screens/chat-detail/PinnedMessagesSheetBackup.d.ts.map +1 -0
  29. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +2 -1
  30. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
  31. package/lib/typescript/src/store/message.d.ts.map +1 -1
  32. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  33. package/lib/typescript/src/types/chat.d.ts +1 -0
  34. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  35. package/lib/typescript/src/utils/UIUtils.d.ts.map +1 -1
  36. package/lib/typescript/src/utils/toastFlashMessage.d.ts +1 -0
  37. package/lib/typescript/src/utils/toastFlashMessage.d.ts.map +1 -1
  38. package/package.json +4 -2
  39. package/src/core/useChatListener.ts +3 -18
  40. package/src/hooks/message/useSendMessage.ts +0 -2
  41. package/src/screens/chat-detail/PinnedMessageBar.tsx +17 -8
  42. package/src/screens/chat-detail/PinnedMessagesSheet.tsx +118 -153
  43. package/src/screens/chat-detail/PinnedMessagesSheetBackup.tsx +253 -0
  44. package/src/screens/chat-detail/legend/LegendChatMessage.tsx +26 -13
  45. package/src/store/message.ts +34 -0
  46. package/src/translation/resources/i18n.ts +4 -2
  47. package/src/types/chat.ts +1 -1
  48. package/src/utils/UIUtils.ts +3 -1
  49. package/src/utils/toastFlashMessage.ts +6 -0
@@ -31,6 +31,7 @@ interface LegendChatMessageProps {
31
31
  onMediaPress?: (items: MediaItem[], index?: number) => void;
32
32
  onPressUrl?: (url: string) => void;
33
33
  onRetry?: (message: MessageItem) => void;
34
+ onPress?: () => void;
34
35
  onLongPress?: () => void;
35
36
  customMessageItemFactory?: (m: MessageItem) => ReactNode;
36
37
  }
@@ -66,6 +67,7 @@ export const LegendChatMessage = memo(
66
67
  onMediaPress,
67
68
  onPressUrl,
68
69
  onRetry,
70
+ onPress,
69
71
  onLongPress,
70
72
  customMessageItemFactory,
71
73
  }: LegendChatMessageProps) => {
@@ -91,7 +93,7 @@ export const LegendChatMessage = memo(
91
93
  onRetry={onRetry}
92
94
  />
93
95
  <KContainer.View style={styles.content}>
94
- <LongPressWrapper onLongPress={onLongPress}>
96
+ <LongPressWrapper onPress={onPress} onLongPress={onLongPress}>
95
97
  <MessageComponent
96
98
  message={message}
97
99
  isOutgoing={isOutgoing}
@@ -139,29 +141,40 @@ const styles = StyleSheet.create({
139
141
  elevation: 3,
140
142
  borderWidth: 1,
141
143
  borderColor: KColors.white,
144
+ zIndex: Number.MAX_SAFE_INTEGER,
142
145
  },
143
146
  });
144
147
 
145
148
  const LongPressWrapper = ({
146
149
  children,
150
+ onPress,
147
151
  onLongPress,
148
- }: PropsWithChildren<{ onLongPress?: () => void }>) => {
149
- const longPressGesture = useMemo(
150
- () =>
151
- onLongPress
152
- ? Gesture.LongPress().onStart(() => {
153
- runOnJS(onLongPress)();
154
- })
155
- : null,
156
- [onLongPress]
157
- );
152
+ }: PropsWithChildren<{ onPress?: () => void; onLongPress?: () => void }>) => {
153
+ const gesture = useMemo(() => {
154
+ const gestures = [
155
+ onLongPress &&
156
+ Gesture.LongPress().onStart(() => {
157
+ runOnJS(onLongPress)();
158
+ }),
159
+ onPress &&
160
+ Gesture.Tap().onStart(() => {
161
+ runOnJS(onPress)();
162
+ }),
163
+ ].filter(Boolean) as ReturnType<typeof Gesture.Tap>[];
164
+
165
+ if (!gestures.length) {
166
+ return null;
167
+ }
168
+
169
+ return gestures.length > 1 ? Gesture.Race(...gestures) : gestures[0];
170
+ }, [onPress, onLongPress]);
158
171
 
159
- if (!longPressGesture) {
172
+ if (!gesture) {
160
173
  return children;
161
174
  }
162
175
 
163
176
  return (
164
- <GestureDetector gesture={longPressGesture}>
177
+ <GestureDetector gesture={gesture}>
165
178
  <KContainer.View>{children}</KContainer.View>
166
179
  </GestureDetector>
167
180
  );
@@ -57,4 +57,38 @@ export const markMessageRevoked = (clientMsgID: string) => {
57
57
  useMessageStore
58
58
  .getState()
59
59
  .updateOneMessage({ clientMsgID, contentType: MessageType.RevokeMessage });
60
+
61
+ revokeQuotedReferences(clientMsgID);
62
+ };
63
+
64
+ const revokeQuotedReferences = (clientMsgID: string) => {
65
+ const { messages, updateOneMessage } = useMessageStore.getState();
66
+
67
+ messages.forEach((msg) => {
68
+ if (msg.quoteElem?.quoteMessage?.clientMsgID === clientMsgID) {
69
+ updateOneMessage({
70
+ clientMsgID: msg.clientMsgID,
71
+ quoteElem: {
72
+ ...msg.quoteElem,
73
+ quoteMessage: {
74
+ ...msg.quoteElem.quoteMessage,
75
+ contentType: MessageType.RevokeMessage,
76
+ },
77
+ },
78
+ });
79
+ }
80
+
81
+ if (msg.atTextElem?.quoteMessage?.clientMsgID === clientMsgID) {
82
+ updateOneMessage({
83
+ clientMsgID: msg.clientMsgID,
84
+ atTextElem: {
85
+ ...msg.atTextElem,
86
+ quoteMessage: {
87
+ ...msg.atTextElem.quoteMessage,
88
+ contentType: MessageType.RevokeMessage,
89
+ },
90
+ },
91
+ });
92
+ }
93
+ });
60
94
  };
@@ -43,15 +43,17 @@ const i18nKey: Record<string, string> = {
43
43
  'chat:pinned_image_subtitle': 'Hình ảnh từ {{sender}}',
44
44
  'chat:pinned_video_subtitle': 'Video từ {{sender}}',
45
45
  'chat:pinned_file_subtitle': 'Tài liệu từ {{sender}}',
46
- 'chat:pinned_link_subtitle': 'Liên kết từ {{sender}}',
46
+ 'chat:pinned_link_subtitle': 'Từ {{sender}}',
47
47
  'chat:pin_limit_title': 'Không thể ghim thêm tin nhắn',
48
48
  'chat:pin_limit_desc':
49
49
  'Chỉ được ghim tối đa 5 tin nhắn. Vui lòng bỏ ghim một tin nhắn hiện có trước khi ghim tin nhắn mới.',
50
50
  'chat:pin_limit_primary': 'Đã hiểu',
51
51
  'chat:pinned_messages_title': 'Tin nhắn đã ghim',
52
52
  'chat:pinned_messages_hint':
53
- 'Nhấn giữ tin nhắn để chọn "Bỏ Ghim" hoặc "Xem tin nhắn gốc"',
53
+ 'Nhấn vào tin nhắn để xem tin nhắn gốc, nhấn vào biểu tượng để bỏ ghim',
54
54
  'chat:view_original_message': 'Xem tin nhắn gốc',
55
+ 'chat:scroll_to_message_todo':
56
+ 'Tính năng di chuyển đến tin nhắn gốc sẽ sớm được cập nhật',
55
57
  'msg_type_image': '[Hình ảnh]',
56
58
  'msg_type_voice': '[Tin nhắn thoại]',
57
59
  'msg_type_video': '[Video]',
package/src/types/chat.ts CHANGED
@@ -28,7 +28,7 @@ export interface ChatUIAdapter {
28
28
  toast?: { open: (params: any) => void };
29
29
  alert?: { open: (params: any) => void };
30
30
  popup?: { open: (params: any) => void };
31
- bottomSheet?: { open: (params: any) => void };
31
+ bottomSheet?: { open: (params: any) => void; dismiss: () => void };
32
32
  }
33
33
 
34
34
  export interface ChatContextType {
@@ -10,7 +10,7 @@ const defaultAdapter: Required<ChatUIAdapter> = {
10
10
  toast: { open: openWithAlert },
11
11
  alert: { open: openWithAlert },
12
12
  popup: { open: openWithAlert },
13
- bottomSheet: { open: openWithAlert },
13
+ bottomSheet: { open: openWithAlert, dismiss: () => {} },
14
14
  };
15
15
 
16
16
  let _adapter: ChatUIAdapter = {};
@@ -32,5 +32,7 @@ export const UIUtils: Required<ChatUIAdapter> = {
32
32
  bottomSheet: {
33
33
  open: (params) =>
34
34
  (_adapter.bottomSheet ?? defaultAdapter.bottomSheet).open(params),
35
+ dismiss: () =>
36
+ (_adapter.bottomSheet ?? defaultAdapter.bottomSheet).dismiss(),
35
37
  },
36
38
  };
@@ -4,6 +4,7 @@ interface ShowFlashMessageParams {
4
4
  key: string;
5
5
  title: string;
6
6
  body?: string;
7
+ ellipsizeMiddle?: boolean;
7
8
  onPress?: () => void;
8
9
  }
9
10
 
@@ -21,6 +22,11 @@ const displayToast = (params: ShowFlashMessageParams) => {
21
22
  onPress: params.onPress,
22
23
  onHide: advanceQueue,
23
24
  visibilityTime: VISIBILITY_TIME_MS,
25
+ text2Props: params.ellipsizeMiddle
26
+ ? {
27
+ ellipsizeMode: 'middle',
28
+ }
29
+ : {},
24
30
  });
25
31
  };
26
32