@smart-link/rn-im 1.0.23 → 1.0.26

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 (170) hide show
  1. package/assets/file-dir.jpg +0 -0
  2. package/dist/api/addressList.js +6 -17
  3. package/dist/api/backup.js +8 -20
  4. package/dist/api/file.js +6 -35
  5. package/dist/api/user.js +6 -16
  6. package/dist/components/CachedImage.js +14 -42
  7. package/dist/components/Camera/Camera.js +26 -54
  8. package/dist/components/Camera/CameraCapture.js +99 -128
  9. package/dist/components/Camera/CameraResult.js +33 -61
  10. package/dist/components/ChatAvatar/ChatAvatar.d.ts +1 -1
  11. package/dist/components/ChatAvatar/ChatAvatar.js +34 -62
  12. package/dist/components/ChatAvatar/ChatAvatarId.d.ts +2 -2
  13. package/dist/components/ChatAvatar/ChatAvatarId.js +26 -51
  14. package/dist/components/ChatAvatar/ChatAvatarLocal.d.ts +2 -2
  15. package/dist/components/ChatAvatar/ChatAvatarLocal.js +22 -25
  16. package/dist/components/ChatAvatar/index.js +2 -23
  17. package/dist/components/Favicon.js +6 -34
  18. package/dist/components/FormatTimeText.js +5 -10
  19. package/dist/components/Highlighter.js +9 -34
  20. package/dist/components/IndicatorText.js +14 -39
  21. package/dist/components/LocalImage.js +7 -32
  22. package/dist/components/NetworkUnconnected.js +14 -42
  23. package/dist/components/PopoverWrapper.js +22 -47
  24. package/dist/components/VideoPlayer.js +111 -138
  25. package/dist/components/styles.js +10 -13
  26. package/dist/default-assets.d.ts +2 -0
  27. package/dist/default-assets.js +9 -10
  28. package/dist/hooks/useDownloadSource.js +7 -12
  29. package/dist/hooks/useFormatMsgTime.js +5 -13
  30. package/dist/hooks/useImReady.js +7 -10
  31. package/dist/hooks/useImSelector.js +34 -48
  32. package/dist/hooks/useTranslation.js +5 -10
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +8 -28
  35. package/dist/init.js +30 -40
  36. package/dist/interface.d.ts +9 -0
  37. package/dist/interface.js +1 -2
  38. package/dist/locales/en/addressList.js +1 -3
  39. package/dist/locales/index.js +4 -27
  40. package/dist/locales/lao/addressList.js +1 -3
  41. package/dist/locales/zh/addressList.js +1 -3
  42. package/dist/pages/address-list/AddressList.js +33 -61
  43. package/dist/pages/address-list/CardInfo.js +10 -18
  44. package/dist/pages/address-list/ChooseContact.js +50 -78
  45. package/dist/pages/address-list/Icons.js +7 -14
  46. package/dist/pages/address-list/Organization.js +59 -89
  47. package/dist/pages/address-list/UserDetail.js +55 -83
  48. package/dist/pages/address-list/UserJobs.js +31 -33
  49. package/dist/pages/address-list/UserSearch.js +29 -54
  50. package/dist/pages/address-list/addressList.routes.js +11 -16
  51. package/dist/pages/collection/Collection.js +53 -81
  52. package/dist/pages/collection/ContentFactory.js +53 -82
  53. package/dist/pages/collection/collection.routes.js +3 -9
  54. package/dist/pages/conversation/ForwardToConversation.js +63 -91
  55. package/dist/pages/conversation/List.js +74 -102
  56. package/dist/pages/conversation/components/ConversationCard.js +46 -74
  57. package/dist/pages/conversation/components/ConversationOption.js +27 -55
  58. package/dist/pages/conversation/conversation.routes.js +17 -23
  59. package/dist/pages/conversation/setting/GroupTransfer.js +32 -60
  60. package/dist/pages/conversation/setting/OptionAvatars.d.ts +1 -1
  61. package/dist/pages/conversation/setting/OptionAvatars.js +62 -90
  62. package/dist/pages/conversation/setting/OptionCancelGroup.js +14 -42
  63. package/dist/pages/conversation/setting/OptionConversation.js +20 -48
  64. package/dist/pages/conversation/setting/OptionGroup.d.ts +1 -1
  65. package/dist/pages/conversation/setting/OptionGroup.js +20 -48
  66. package/dist/pages/conversation/setting/OptionGroupManage.js +21 -49
  67. package/dist/pages/conversation/setting/OptionGroupMoreMember.js +48 -53
  68. package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.js +49 -77
  69. package/dist/pages/conversation/setting/Setting.js +50 -56
  70. package/dist/pages/conversation/setting/SettingChatBg.js +26 -54
  71. package/dist/pages/index.js +7 -27
  72. package/dist/pages/message/ChooseMember.js +56 -84
  73. package/dist/pages/message/FileSelector.d.ts +6 -0
  74. package/dist/pages/message/FileSelector.js +235 -0
  75. package/dist/pages/message/MessageBackup/Bar.js +18 -43
  76. package/dist/pages/message/MessageBackup/MessageBackup.js +42 -72
  77. package/dist/pages/message/MessageBackup/RestoreBackupPage.js +48 -76
  78. package/dist/pages/message/MessageBackup/StartBackupPage.js +48 -76
  79. package/dist/pages/message/MessageBackup/index.js +3 -12
  80. package/dist/pages/message/MessageBackup/utils.js +14 -22
  81. package/dist/pages/message/MessageList.js +151 -141
  82. package/dist/pages/message/MessageRecord.js +74 -87
  83. package/dist/pages/message/components/BusiNotifyCard.js +60 -85
  84. package/dist/pages/message/components/ChatBg.js +11 -36
  85. package/dist/pages/message/components/MessageItem.d.ts +2 -1
  86. package/dist/pages/message/components/MessageItem.js +85 -112
  87. package/dist/pages/message/components/MessageItemQuote.js +30 -58
  88. package/dist/pages/message/components/MessageItemTips.js +27 -55
  89. package/dist/pages/message/components/MessageOption.d.ts +7 -3
  90. package/dist/pages/message/components/MessageOption.js +107 -134
  91. package/dist/pages/message/components/MessagePayload.d.ts +2 -1
  92. package/dist/pages/message/components/MessagePayload.js +36 -64
  93. package/dist/pages/message/components/MessagePictureAlbum.js +32 -60
  94. package/dist/pages/message/components/MessageReceiptStatus.js +18 -43
  95. package/dist/pages/message/components/MessageUndo.js +18 -48
  96. package/dist/pages/message/components/MultipleBar/index.js +48 -76
  97. package/dist/pages/message/components/Payload/PayloadContact.js +30 -58
  98. package/dist/pages/message/components/Payload/PayloadFile.d.ts +1 -1
  99. package/dist/pages/message/components/Payload/PayloadFile.js +44 -68
  100. package/dist/pages/message/components/Payload/PayloadMultiple.js +46 -70
  101. package/dist/pages/message/components/Payload/PayloadNotify.js +28 -56
  102. package/dist/pages/message/components/Payload/PayloadPicture.d.ts +1 -1
  103. package/dist/pages/message/components/Payload/PayloadPicture.js +21 -50
  104. package/dist/pages/message/components/Payload/PayloadShare.js +39 -67
  105. package/dist/pages/message/components/Payload/PayloadText.js +39 -67
  106. package/dist/pages/message/components/Payload/PayloadVideo.js +30 -57
  107. package/dist/pages/message/components/Payload/PayloadVoice.js +80 -93
  108. package/dist/pages/message/components/Payload/PayloadWrapper.d.ts +2 -1
  109. package/dist/pages/message/components/Payload/PayloadWrapper.js +24 -44
  110. package/dist/pages/message/components/Payload/type.d.ts +2 -1
  111. package/dist/pages/message/components/Payload/type.js +1 -2
  112. package/dist/pages/message/components/ReceiptBack.js +30 -60
  113. package/dist/pages/message/components/TextMixMessage.js +13 -38
  114. package/dist/pages/message/components/TextMixQuote.js +128 -162
  115. package/dist/pages/message/components/TextMixQuoteMessage.js +19 -47
  116. package/dist/pages/message/components/UploadProgress.js +12 -37
  117. package/dist/pages/message/components/messageBar/EmojiPanel.js +25 -50
  118. package/dist/pages/message/components/messageBar/Icons.js +56 -74
  119. package/dist/pages/message/components/messageBar/MessageBar.js +84 -115
  120. package/dist/pages/message/components/messageBar/MessageInput.js +30 -55
  121. package/dist/pages/message/components/messageBar/OptionPanel.js +54 -107
  122. package/dist/pages/message/components/messageBar/VoiceBar.js +122 -100
  123. package/dist/pages/message/components/messageBar/index.js +2 -23
  124. package/dist/pages/message/message.routes.js +21 -40
  125. package/dist/pages/search/Search.js +38 -66
  126. package/dist/pages/search/SearchChatRecords.js +64 -92
  127. package/dist/pages/search/SearchFile.js +68 -96
  128. package/dist/pages/search/SearchManager.js +60 -65
  129. package/dist/pages/search/SearchPicturePage.js +16 -44
  130. package/dist/pages/search/components/ChatRecords.js +46 -74
  131. package/dist/pages/search/components/MyGroupChat.js +41 -69
  132. package/dist/pages/search/components/PictureMulipleBar.js +35 -63
  133. package/dist/pages/search/components/SearchFileList.js +59 -64
  134. package/dist/pages/search/components/SearchPictures.js +68 -98
  135. package/dist/pages/search/components/SearchShareLinkList.js +50 -55
  136. package/dist/pages/search/components/SearchUser.js +25 -53
  137. package/dist/pages/search/components/useSearchMessage.js +12 -16
  138. package/dist/pages/search/search.routes.js +11 -17
  139. package/dist/pages/search/utils.js +4 -12
  140. package/dist/pages/types.d.ts +4 -2
  141. package/dist/pages/types.js +1 -2
  142. package/dist/slice/contact/contact.slice.js +4 -8
  143. package/dist/slice/index.js +7 -13
  144. package/dist/slice/panel/panel.slice.d.ts +2 -1
  145. package/dist/slice/panel/panel.slice.js +8 -7
  146. package/dist/slice/video/video.action.d.ts +1 -0
  147. package/dist/slice/video/video.action.js +64 -38
  148. package/dist/slice/video/video.slice.d.ts +1 -1
  149. package/dist/slice/video/video.slice.js +7 -8
  150. package/dist/utils/audio.d.ts +3 -0
  151. package/dist/utils/audio.js +10 -0
  152. package/dist/utils/color.js +2 -9
  153. package/dist/utils/common-action-sheet.js +9 -14
  154. package/dist/utils/cookie.js +6 -14
  155. package/dist/utils/emoji.js +9 -12
  156. package/dist/utils/file-icon.js +33 -60
  157. package/dist/utils/file-operate.js +1 -2
  158. package/dist/utils/file.d.ts +10 -2
  159. package/dist/utils/file.js +188 -88
  160. package/dist/utils/golden-rectangle.js +3 -7
  161. package/dist/utils/phone.js +13 -22
  162. package/dist/utils/request.js +7 -15
  163. package/dist/utils/scroll.js +5 -9
  164. package/dist/utils/summary.js +4 -11
  165. package/dist/utils/take-camera.js +12 -19
  166. package/dist/utils/text-mix.js +4 -11
  167. package/dist/utils/upload.js +20 -41
  168. package/package.json +6 -7
  169. package/dist/slice/contact/contact.action.d.ts +0 -1
  170. package/dist/slice/contact/contact.action.js +0 -2
@@ -1,100 +1,72 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const react_1 = __importStar(require("react"));
30
- const useTranslation_1 = __importDefault(require("../../../../hooks/useTranslation"));
31
- const rn_ui_1 = require("@smart-link/rn-ui");
32
- const react_native_1 = require("react-native");
33
- const PayloadWrapper_1 = __importDefault(require("./PayloadWrapper"));
34
- const styles_1 = require("../../../../components/styles");
35
- const Favicon_1 = __importDefault(require("../../../../components/Favicon"));
36
- const size = (0, rn_ui_1.dp)(45);
1
+ import React, { memo } from 'react';
2
+ import useTranslation from "../../../../hooks/useTranslation";
3
+ import { dp } from "@smart-link/rn-ui";
4
+ import { Linking, StyleSheet, Text, View } from "react-native";
5
+ import PayloadWrapper from "./PayloadWrapper";
6
+ import { borderStyle, shadowStyle } from "../../../../components/styles";
7
+ import Favicon from "../../../../components/Favicon";
8
+ const size = dp(45);
37
9
  // const backgroundColor = '#fff';
38
10
  const borderColor = '#eee';
39
11
  const PayloadShare = ({ payload, direction, showArrow = true, style, onLongPress }) => {
40
- const { t } = (0, useTranslation_1.default)();
12
+ const { t } = useTranslation();
41
13
  const { title, url, description } = payload;
42
- return (<PayloadWrapper_1.default direction={direction} showArrow={showArrow} style={[style, styles.share]} onPress={() => {
14
+ return (<PayloadWrapper direction={direction} showArrow={showArrow} style={[style, styles.share]} onPress={() => {
43
15
  if (url === null || url === void 0 ? void 0 : url.startsWith('http')) {
44
- react_native_1.Linking.openURL(url);
16
+ Linking.openURL(url);
45
17
  }
46
18
  }} onLongPress={onLongPress}>
47
- <react_native_1.View style={styles.card}>
48
- <react_native_1.Text style={styles.title} numberOfLines={2}>{title}</react_native_1.Text>
49
- <react_native_1.View style={styles.h5}/>
50
- <react_native_1.View style={styles.info}>
51
- <react_native_1.Text style={styles.description} numberOfLines={3}>{description}</react_native_1.Text>
52
- <react_native_1.View style={styles.w10}/>
19
+ <View style={styles.card}>
20
+ <Text style={styles.title} numberOfLines={2}>{title}</Text>
21
+ <View style={styles.h5}/>
22
+ <View style={styles.info}>
23
+ <Text style={styles.description} numberOfLines={3}>{description}</Text>
24
+ <View style={styles.w10}/>
53
25
  {/* favicon */}
54
- <Favicon_1.default url={url} size={size}/>
55
- </react_native_1.View>
56
- </react_native_1.View>
57
- <react_native_1.View style={styles.line}/>
58
- <react_native_1.Text style={styles.shareName}>{t('shareLink')}</react_native_1.Text>
59
- </PayloadWrapper_1.default>);
26
+ <Favicon url={url} size={size}/>
27
+ </View>
28
+ </View>
29
+ <View style={styles.line}/>
30
+ <Text style={styles.shareName}>{t('shareLink')}</Text>
31
+ </PayloadWrapper>);
60
32
  };
61
- const styles = react_native_1.StyleSheet.create({
33
+ const styles = StyleSheet.create({
62
34
  share: Object.assign(Object.assign(Object.assign({
63
35
  // backgroundColor,
64
- paddingHorizontal: (0, rn_ui_1.dp)(10), paddingTop: (0, rn_ui_1.dp)(10), paddingBottom: (0, rn_ui_1.dp)(5) }, styles_1.shadowStyle), styles_1.borderStyle), { borderColor }),
36
+ paddingHorizontal: dp(10), paddingTop: dp(10), paddingBottom: dp(5) }, shadowStyle), borderStyle), { borderColor }),
65
37
  card: {},
66
38
  title: {
67
- width: (0, rn_ui_1.dp)(230),
39
+ width: dp(230),
68
40
  color: '#333',
69
- lineHeight: (0, rn_ui_1.dp)(20),
70
- fontSize: (0, rn_ui_1.dp)(14),
41
+ lineHeight: dp(20),
42
+ fontSize: dp(14),
71
43
  },
72
44
  description: {
73
- width: (0, rn_ui_1.dp)(180),
45
+ width: dp(180),
74
46
  color: '#999',
75
- lineHeight: (0, rn_ui_1.dp)(18),
76
- fontSize: (0, rn_ui_1.dp)(12),
47
+ lineHeight: dp(18),
48
+ fontSize: dp(12),
77
49
  },
78
50
  info: {
79
51
  flexDirection: 'row',
80
52
  },
81
53
  h5: {
82
- height: (0, rn_ui_1.dp)(5),
54
+ height: dp(5),
83
55
  },
84
56
  w10: {
85
- width: (0, rn_ui_1.dp)(10),
57
+ width: dp(10),
86
58
  },
87
59
  line: {
88
- marginTop: (0, rn_ui_1.dp)(10),
89
- marginBottom: (0, rn_ui_1.dp)(5),
60
+ marginTop: dp(10),
61
+ marginBottom: dp(5),
90
62
  backgroundColor: '#eee',
91
63
  width: '100%',
92
- height: (0, rn_ui_1.dp)(1),
64
+ height: dp(1),
93
65
  },
94
66
  shareName: {
95
67
  color: '#777',
96
- paddingLeft: (0, rn_ui_1.dp)(3),
97
- fontSize: (0, rn_ui_1.dp)(13),
68
+ paddingLeft: dp(3),
69
+ fontSize: dp(13),
98
70
  }
99
71
  });
100
- exports.default = (0, react_1.memo)(PayloadShare);
72
+ export default memo(PayloadShare);
@@ -1,72 +1,44 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const react_1 = __importStar(require("react"));
30
- const react_native_1 = require("react-native");
31
- const styles_1 = require("../../../../components/styles");
32
- const rn_ui_1 = require("@smart-link/rn-ui");
33
- const TextMixQuoteMessage_1 = __importDefault(require("../TextMixQuoteMessage"));
34
- const useTranslation_1 = __importDefault(require("../../../../hooks/useTranslation"));
35
- const phone_1 = require("../../../../utils/phone");
36
- const PayloadWrapper_1 = __importDefault(require("./PayloadWrapper"));
37
- const init_1 = require("../../../../init");
38
- const im_base_1 = require("@smart-link/im-base");
39
- const clipboard_1 = __importDefault(require("@react-native-clipboard/clipboard"));
1
+ import React, { memo } from 'react';
2
+ import { Dimensions, StyleSheet, Linking } from 'react-native';
3
+ import { borderStyle, plain, shadowStyle } from '../../../../components/styles';
4
+ import { ActionSheet, dp, Toast } from '@smart-link/rn-ui';
5
+ import TextMixQuoteMessage from '../TextMixQuoteMessage';
6
+ import useTranslation from '../../../../hooks/useTranslation';
7
+ import { addContacts, callPhone, copyPhone } from '../../../../utils/phone';
8
+ import PayloadWrapper from './PayloadWrapper';
9
+ import { getImManager } from '../../../../init';
10
+ import { MessagePanelActions } from '@smart-link/im-base';
11
+ import Clipboard from '@react-native-clipboard/clipboard';
40
12
  const PayloadText = ({ payload, onLongPress, onPress, isRecord, showArrow = true, direction, style }) => {
41
- const { t } = (0, useTranslation_1.default)();
13
+ const { t } = useTranslation();
42
14
  const { text, quote } = payload;
43
15
  const onLongPressPhone = (phone) => {
44
- rn_ui_1.ActionSheet.open({
16
+ ActionSheet.open({
45
17
  title: phone + " " + t('mayPhone'),
46
18
  onClose: () => {
47
- rn_ui_1.ActionSheet.destroy();
19
+ ActionSheet.destroy();
48
20
  },
49
21
  options: [
50
22
  {
51
23
  text: t('copy'),
52
24
  onPress: () => {
53
- (0, phone_1.copyPhone)(phone);
54
- rn_ui_1.ActionSheet.destroy();
55
- rn_ui_1.Toast.info(t('copied'));
25
+ copyPhone(phone);
26
+ ActionSheet.destroy();
27
+ Toast.info(t('copied'));
56
28
  }
57
29
  },
58
30
  {
59
31
  text: t('callPhone'),
60
32
  onPress: () => {
61
- (0, phone_1.callPhone)(phone);
62
- rn_ui_1.ActionSheet.destroy();
33
+ callPhone(phone);
34
+ ActionSheet.destroy();
63
35
  },
64
36
  },
65
37
  {
66
38
  text: t('addToContacts'),
67
39
  onPress: () => {
68
- (0, phone_1.addContacts)(phone);
69
- rn_ui_1.ActionSheet.destroy();
40
+ addContacts(phone);
41
+ ActionSheet.destroy();
70
42
  }
71
43
  }
72
44
  ],
@@ -76,25 +48,25 @@ const PayloadText = ({ payload, onLongPress, onPress, isRecord, showArrow = true
76
48
  });
77
49
  };
78
50
  const onLongPressURL = (url) => {
79
- rn_ui_1.ActionSheet.open({
51
+ ActionSheet.open({
80
52
  title: url,
81
53
  onClose: () => {
82
- rn_ui_1.ActionSheet.destroy();
54
+ ActionSheet.destroy();
83
55
  },
84
56
  options: [
85
57
  {
86
58
  text: t('openURL'),
87
59
  onPress: () => {
88
- react_native_1.Linking.openURL(url);
89
- rn_ui_1.ActionSheet.destroy();
90
- rn_ui_1.Toast.info(t('copied'));
60
+ Linking.openURL(url);
61
+ ActionSheet.destroy();
62
+ Toast.info(t('copied'));
91
63
  }
92
64
  },
93
65
  {
94
66
  text: t('copyURL'),
95
67
  onPress: () => {
96
- clipboard_1.default.setString(url);
97
- rn_ui_1.ActionSheet.destroy();
68
+ Clipboard.setString(url);
69
+ ActionSheet.destroy();
98
70
  },
99
71
  },
100
72
  ],
@@ -109,24 +81,24 @@ const PayloadText = ({ payload, onLongPress, onPress, isRecord, showArrow = true
109
81
  onPress === null || onPress === void 0 ? void 0 : onPress();
110
82
  return;
111
83
  }
112
- const imManager = (0, init_1.getImManager)();
113
- imManager.store.dispatch(im_base_1.MessagePanelActions.onPressQuote(imManager, quoteMessageSeq));
84
+ const imManager = getImManager();
85
+ imManager.store.dispatch(MessagePanelActions.onPressQuote(imManager, quoteMessageSeq));
114
86
  };
115
- return (<PayloadWrapper_1.default direction={direction} showArrow={showArrow} onLongPress={onLongPress} style={[style, styles_1.plain]}>
116
- <TextMixQuoteMessage_1.default text={text} quote={quote} textStyle={[styles.text]} quoteStyle={styles.quote} quoteBgColor='#fff' onLongPressPhone={onLongPressPhone} onLongPressURL={onLongPressURL} onPressQuote={onPressQuote}/>
117
- </PayloadWrapper_1.default>);
87
+ return (<PayloadWrapper direction={direction} showArrow={showArrow} onLongPress={onLongPress} style={[style, plain]}>
88
+ <TextMixQuoteMessage text={text} quote={quote} textStyle={[styles.text]} quoteStyle={styles.quote} quoteBgColor='#fff' onLongPressPhone={onLongPressPhone} onLongPressURL={onLongPressURL} onPressQuote={onPressQuote}/>
89
+ </PayloadWrapper>);
118
90
  };
119
- const styles = react_native_1.StyleSheet.create({
120
- popoverTextMix: Object.assign(Object.assign({ alignSelf: 'flex-start', maxWidth: react_native_1.Dimensions.get('window').width - 120, padding: (0, rn_ui_1.dp)(8) }, styles_1.borderStyle), styles_1.shadowStyle),
91
+ const styles = StyleSheet.create({
92
+ popoverTextMix: Object.assign(Object.assign({ alignSelf: 'flex-start', maxWidth: Dimensions.get('window').width - 120, padding: dp(8) }, borderStyle), shadowStyle),
121
93
  h5: {
122
- height: (0, rn_ui_1.dp)(5),
94
+ height: dp(5),
123
95
  },
124
96
  text: {
125
97
  color: '#222',
126
- fontSize: (0, rn_ui_1.dp)(14),
98
+ fontSize: dp(14),
127
99
  },
128
100
  quote: {
129
- padding: (0, rn_ui_1.dp)(6)
101
+ padding: dp(6)
130
102
  },
131
103
  });
132
- exports.default = (0, react_1.memo)(PayloadText);
104
+ export default memo(PayloadText);
@@ -1,67 +1,40 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const react_1 = __importStar(require("react"));
30
- const im_base_1 = require("@smart-link/im-base");
31
- const rn_ui_1 = require("@smart-link/rn-ui");
32
- const react_native_1 = require("react-native");
33
- const file_1 = require("../../../../api/file");
34
- const golden_rectangle_1 = require("../../../../utils/golden-rectangle");
35
- const MaterialIcons_1 = __importDefault(require("react-native-vector-icons/MaterialIcons"));
36
- const video_action_1 = require("../../../../slice/video/video.action");
37
- const styles_1 = require("../../../../components/styles");
38
- const UploadProgress_1 = __importDefault(require("../UploadProgress"));
39
- const PayloadWrapper_1 = __importDefault(require("./PayloadWrapper"));
40
- const init_1 = require("../../../../init");
41
- const react_native_fast_image_1 = __importDefault(require("react-native-fast-image"));
1
+ import React, { memo } from 'react';
2
+ import { MessageStatus, numberToTime } from '@smart-link/im-base';
3
+ import { dp } from '@smart-link/rn-ui';
4
+ import { StyleSheet, View, Text } from 'react-native';
5
+ import { getDownloadUrl } from '../../../../api/file';
6
+ import { calculate } from '../../../../utils/golden-rectangle';
7
+ import Icon from 'react-native-vector-icons/MaterialIcons';
8
+ import { loadVideoPlayer } from '../../../../slice/video/video.action';
9
+ import { borderStyle, shadowStyle } from '../../../../components/styles';
10
+ import UploadProgress from '../UploadProgress';
11
+ import PayloadWrapper from './PayloadWrapper';
12
+ import { getImManager } from '../../../../init';
13
+ import Image from 'react-native-fast-image';
14
+ import { toAbsolutePath } from "../../../../utils/file";
42
15
  const PayloadVideo = ({ messageStatus, messageSeq, payload, sendSize = 0, isRecord, onLongPress }) => {
43
16
  const { width, height } = payload;
44
- const size = (0, golden_rectangle_1.calculate)(height || (0, rn_ui_1.dp)(163), width || (0, rn_ui_1.dp)(100));
45
- const thumbnail = payload.imagePath ? { uri: 'file://' + payload.imagePath }
46
- : { uri: (0, file_1.getDownloadUrl)(payload.imageFileId) };
47
- return (<PayloadWrapper_1.default style={[styles.root, styles_1.shadowStyle, styles_1.borderStyle, size]} onPress={() => {
48
- (0, init_1.getImManager)().store.dispatch((0, video_action_1.loadVideoPlayer)({
17
+ const size = calculate(height || dp(163), width || dp(100));
18
+ const thumbnail = payload.imagePath ? { uri: toAbsolutePath(payload.imagePath) }
19
+ : { uri: getDownloadUrl(payload.imageFileId) };
20
+ return (<PayloadWrapper style={[styles.root, shadowStyle, borderStyle, size]} onPress={() => {
21
+ getImManager().store.dispatch(loadVideoPlayer({
49
22
  messageSeq,
50
23
  payload,
51
24
  isRecord
52
25
  }));
53
26
  }} onLongPress={onLongPress}>
54
- {payload.imagePath || payload.imageFileId ? <react_native_fast_image_1.default style={[size, styles_1.borderStyle]} resizeMode='cover' source={thumbnail}/> : <react_native_1.View style={[size, styles_1.borderStyle, { backgroundColor: '#000' }]}/>}
55
- <UploadProgress_1.default show={messageStatus === im_base_1.MessageStatus.EMITTING && !payload.fileId && payload.size > 0} width={size.width} sendSize={sendSize} totalSize={payload.size}/>
56
- <react_native_1.View style={styles.playView}>
57
- <MaterialIcons_1.default size={30} name='play-circle-outline' color='#fff'/>
58
- </react_native_1.View>
59
- <react_native_1.View style={{ position: 'absolute', bottom: (0, rn_ui_1.dp)(5), right: (0, rn_ui_1.dp)(5) }}>
60
- <react_native_1.Text style={{ fontSize: (0, rn_ui_1.dp)(12), color: '#fff' }}>{(0, im_base_1.numberToTime)(payload.duration)}</react_native_1.Text>
61
- </react_native_1.View>
62
- </PayloadWrapper_1.default>);
27
+ {payload.imagePath || payload.imageFileId ? <Image style={[size, borderStyle]} resizeMode='cover' source={thumbnail}/> : <View style={[size, borderStyle, { backgroundColor: '#000' }]}/>}
28
+ <UploadProgress show={messageStatus === MessageStatus.EMITTING && !payload.fileId && payload.size > 0} width={size.width} sendSize={sendSize} totalSize={payload.size}/>
29
+ <View style={styles.playView}>
30
+ <Icon size={30} name='play-circle-outline' color='#fff'/>
31
+ </View>
32
+ <View style={{ position: 'absolute', bottom: dp(5), right: dp(5) }}>
33
+ <Text style={{ fontSize: dp(12), color: '#fff' }}>{numberToTime(payload.duration)}</Text>
34
+ </View>
35
+ </PayloadWrapper>);
63
36
  };
64
- const styles = react_native_1.StyleSheet.create({
37
+ const styles = StyleSheet.create({
65
38
  root: {
66
39
  backgroundColor: 'rgba(0,0,0, 0.8)',
67
40
  },
@@ -75,4 +48,4 @@ const styles = react_native_1.StyleSheet.create({
75
48
  alignItems: 'center',
76
49
  },
77
50
  });
78
- exports.default = (0, react_1.memo)(PayloadVideo);
51
+ export default memo(PayloadVideo);
@@ -1,27 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,66 +7,75 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
8
  });
33
9
  };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- const react_1 = __importStar(require("react"));
39
- const react_native_1 = require("react-native");
40
- const rn_ui_1 = require("@smart-link/rn-ui");
41
- const react_native_audio_recorder_player_1 = __importDefault(require("react-native-audio-recorder-player"));
42
- const PayloadWrapper_1 = __importDefault(require("./PayloadWrapper"));
43
- const variables_1 = __importDefault(require("@smart-link/rn-ui/dist/components/styles/variables"));
44
- const init_1 = require("../../../../init");
45
- const im_base_1 = require("@smart-link/im-base");
46
- const file_1 = require("../../../../utils/file");
47
- const react_native_fast_image_1 = __importDefault(require("react-native-fast-image"));
10
+ import React, { memo, useRef } from 'react';
11
+ import { Text, StyleSheet, View } from 'react-native';
12
+ import { dp } from '@smart-link/rn-ui';
13
+ import PayloadWrapper from './PayloadWrapper';
14
+ import variables from '@smart-link/rn-ui/dist/components/styles/variables';
15
+ import { getImManager } from '../../../../init';
16
+ import { MessageActions } from '@smart-link/im-base';
17
+ import { toAbsolutePath } from "../../../../utils/file";
18
+ import Image from 'react-native-fast-image';
19
+ import { AudioPlayer } from "../../../../utils/audio";
20
+ import RNFS from "react-native-fs";
21
+ import { usePanel } from "../../../../hooks/useImSelector";
22
+ import { setVoicePlayingSeq } from "../../../../slice/panel/panel.slice";
48
23
  const voiceLeft = require('../../../../../assets/voice-left.png');
49
24
  const voiceLeftPlaying = require('../../../../../assets/voice-left-playing.gif');
50
- const audioRecorderPlayer = new react_native_audio_recorder_player_1.default();
51
25
  const PayloadVoice = ({ payload, direction, style, messageSeq, showArrow = true, onLongPress }) => {
52
- console.log('PayloadVoice: messageSeq:', messageSeq);
53
- (0, react_1.useEffect)(() => {
54
- return () => {
55
- audioRecorderPlayer.removePlayBackListener();
56
- };
57
- }, []);
58
26
  const second = Math.round(payload.duration);
27
+ const { voicePlayingSeq } = usePanel();
59
28
  const voiceWidth = Math.min(120, 40 + (80 * (isNaN(second) ? 15 : second)) / 60);
60
- const [playing, setPlaying] = (0, react_1.useState)(false);
61
- const downloading = (0, react_1.useRef)(false);
29
+ const playing = voicePlayingSeq === messageSeq;
30
+ const downloading = useRef(false);
31
+ const imManager = getImManager();
32
+ const updateRead = (destPath) => {
33
+ imManager.db.updateMessage({
34
+ messageSeq: messageSeq,
35
+ payload: Object.assign(Object.assign({}, payload), { localPath: destPath, read: true }),
36
+ });
37
+ imManager.store.dispatch(MessageActions.updateMessage(messageSeq, {
38
+ payload: Object.assign(Object.assign({}, payload), { localPath: destPath, read: true }),
39
+ }));
40
+ };
41
+ const download = () => __awaiter(void 0, void 0, void 0, function* () {
42
+ const imManager = getImManager();
43
+ const destPath = yield imManager.download({
44
+ fileId: payload.fileId,
45
+ resourceType: 'voice',
46
+ filename: payload.filename,
47
+ });
48
+ updateRead(destPath);
49
+ return destPath;
50
+ });
62
51
  const startPlayer = (path) => __awaiter(void 0, void 0, void 0, function* () {
63
- audioRecorderPlayer.addPlayBackListener((e) => {
64
- setPlaying(!e.isFinished);
65
- if (e.isFinished) {
66
- audioRecorderPlayer.removePlayBackListener();
52
+ if (voicePlayingSeq === messageSeq) {
53
+ yield AudioPlayer.stopPlayer();
54
+ imManager.store.dispatch(setVoicePlayingSeq(''));
55
+ return;
56
+ }
57
+ else {
58
+ if (voicePlayingSeq) {
59
+ yield AudioPlayer.stopPlayer();
60
+ imManager.store.dispatch(setVoicePlayingSeq(''));
67
61
  }
68
- });
62
+ }
63
+ imManager.store.dispatch(setVoicePlayingSeq(messageSeq));
69
64
  try {
70
65
  console.log('startPlayer: ', path);
71
- yield audioRecorderPlayer.startPlayer((0, file_1.toAbsolutePath)(path));
66
+ yield AudioPlayer.startPlayer(toAbsolutePath(path));
72
67
  }
73
68
  catch (err) {
74
69
  console.log(err);
70
+ imManager.store.dispatch(setVoicePlayingSeq(''));
75
71
  }
76
72
  });
77
73
  const handlePlay = () => __awaiter(void 0, void 0, void 0, function* () {
78
- const imManager = (0, init_1.getImManager)();
74
+ console.log('handlePlay');
79
75
  if (!payload.localPath && payload.fileId && !downloading.current) {
80
76
  // 下载文件
81
77
  downloading.current = true;
82
- const destPath = yield imManager.download({
83
- fileId: payload.fileId,
84
- resourceType: 'voice',
85
- filename: payload.filename,
86
- });
87
- imManager.db.updateMessage({
88
- messageSeq: messageSeq,
89
- payload: Object.assign(Object.assign({}, payload), { localPath: destPath, read: true }),
90
- });
91
- imManager.store.dispatch(im_base_1.MessageActions.updateMessage(messageSeq, {
92
- payload: Object.assign(Object.assign({}, payload), { localPath: destPath, read: true }),
93
- }));
78
+ const destPath = yield download();
94
79
  yield startPlayer(destPath);
95
80
  return;
96
81
  }
@@ -98,21 +83,23 @@ const PayloadVoice = ({ payload, direction, style, messageSeq, showArrow = true,
98
83
  return;
99
84
  }
100
85
  else {
101
- // 更新已读状态
102
- imManager.db.updateMessage({
103
- messageSeq: messageSeq,
104
- payload: Object.assign(Object.assign({}, payload), { read: true }),
105
- });
106
- imManager.store.dispatch(im_base_1.MessageActions.updateMessage(messageSeq, {
107
- payload: Object.assign(Object.assign({}, payload), { read: true }),
108
- }));
109
- yield startPlayer(payload.localPath);
86
+ const isExist = yield RNFS.exists(toAbsolutePath(payload.localPath));
87
+ if (!isExist) {
88
+ console.log('path not exists');
89
+ const destPath = yield download();
90
+ yield startPlayer(destPath);
91
+ return;
92
+ }
93
+ else {
94
+ updateRead(payload.localPath);
95
+ yield startPlayer(payload.localPath);
96
+ }
110
97
  }
111
98
  });
112
- return (<react_native_1.View style={[styles.root, { flexDirection: direction === 'left' ? 'row' : 'row-reverse' }]}>
113
- <PayloadWrapper_1.default showArrow={showArrow} direction={direction} onPress={handlePlay} onLongPress={onLongPress} style={[style, styles.popoverVoice, { width: voiceWidth + 15 }]}>
114
- <react_native_1.Text style={styles.duration}>{second}''</react_native_1.Text>
115
- <react_native_fast_image_1.default style={[
99
+ return (<View style={[styles.root, { flexDirection: direction === 'left' ? 'row' : 'row-reverse' }]}>
100
+ <PayloadWrapper showArrow={showArrow} direction={direction} onPress={handlePlay} onLongPress={onLongPress} style={[style, styles.popoverVoice, { width: voiceWidth + 15 }]}>
101
+ <Text style={styles.duration}>{second}''</Text>
102
+ <Image style={[
116
103
  styles.voiceImage,
117
104
  {
118
105
  transform: [
@@ -121,12 +108,12 @@ const PayloadVoice = ({ payload, direction, style, messageSeq, showArrow = true,
121
108
  },
122
109
  ],
123
110
  },
124
- ]} source={playing ? voiceLeftPlaying : voiceLeft}></react_native_fast_image_1.default>
125
- </PayloadWrapper_1.default>
126
- {!payload.read && direction === 'left' && <react_native_1.View style={styles.dot}/>}
127
- </react_native_1.View>);
111
+ ]} source={playing ? voiceLeftPlaying : voiceLeft}></Image>
112
+ </PayloadWrapper>
113
+ {!payload.read && direction === 'left' && <View style={styles.dot}/>}
114
+ </View>);
128
115
  };
129
- const styles = react_native_1.StyleSheet.create({
116
+ const styles = StyleSheet.create({
130
117
  root: {
131
118
  display: 'flex',
132
119
  flexDirection: 'row',
@@ -134,22 +121,22 @@ const styles = react_native_1.StyleSheet.create({
134
121
  },
135
122
  popoverVoice: {
136
123
  flexDirection: 'row',
137
- padding: (0, rn_ui_1.dp)(9),
124
+ padding: dp(9),
138
125
  },
139
126
  voiceImage: {
140
- width: (0, rn_ui_1.dp)(24),
141
- height: (0, rn_ui_1.dp)(18),
127
+ width: dp(24),
128
+ height: dp(18),
142
129
  },
143
130
  duration: {
144
- fontSize: (0, rn_ui_1.dp)(13),
131
+ fontSize: dp(13),
145
132
  color: '#666',
146
133
  alignSelf: 'center',
147
134
  },
148
135
  dot: {
149
- width: (0, rn_ui_1.dp)(6),
150
- height: (0, rn_ui_1.dp)(6),
151
- borderRadius: (0, rn_ui_1.dp)(3),
152
- backgroundColor: variables_1.default.red6,
136
+ width: dp(6),
137
+ height: dp(6),
138
+ borderRadius: dp(3),
139
+ backgroundColor: variables.red6,
153
140
  }
154
141
  });
155
- exports.default = (0, react_1.memo)(PayloadVoice);
142
+ export default memo(PayloadVoice);