@smart-link/rn-im 1.0.23 → 1.0.24
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.
- package/dist/api/addressList.js +6 -17
- package/dist/api/backup.js +8 -20
- package/dist/api/file.js +6 -35
- package/dist/api/user.js +6 -16
- package/dist/components/CachedImage.js +14 -42
- package/dist/components/Camera/Camera.js +26 -54
- package/dist/components/Camera/CameraCapture.js +99 -128
- package/dist/components/Camera/CameraResult.js +33 -61
- package/dist/components/ChatAvatar/ChatAvatar.d.ts +1 -1
- package/dist/components/ChatAvatar/ChatAvatar.js +34 -62
- package/dist/components/ChatAvatar/ChatAvatarId.d.ts +2 -2
- package/dist/components/ChatAvatar/ChatAvatarId.js +26 -51
- package/dist/components/ChatAvatar/ChatAvatarLocal.d.ts +2 -2
- package/dist/components/ChatAvatar/ChatAvatarLocal.js +23 -25
- package/dist/components/ChatAvatar/index.js +2 -23
- package/dist/components/Favicon.js +6 -34
- package/dist/components/FormatTimeText.js +5 -10
- package/dist/components/Highlighter.js +9 -34
- package/dist/components/IndicatorText.js +14 -39
- package/dist/components/LocalImage.js +7 -32
- package/dist/components/NetworkUnconnected.js +14 -42
- package/dist/components/PopoverWrapper.js +22 -47
- package/dist/components/VideoPlayer.js +111 -138
- package/dist/components/styles.js +10 -13
- package/dist/default-assets.d.ts +1 -0
- package/dist/default-assets.js +8 -10
- package/dist/hooks/useDownloadSource.js +7 -12
- package/dist/hooks/useFormatMsgTime.js +5 -13
- package/dist/hooks/useImReady.js +7 -10
- package/dist/hooks/useImSelector.js +34 -48
- package/dist/hooks/useTranslation.js +5 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -28
- package/dist/init.js +30 -40
- package/dist/interface.js +1 -2
- package/dist/locales/en/addressList.js +1 -3
- package/dist/locales/index.js +4 -27
- package/dist/locales/lao/addressList.js +1 -3
- package/dist/locales/zh/addressList.js +1 -3
- package/dist/pages/address-list/AddressList.js +33 -61
- package/dist/pages/address-list/CardInfo.js +10 -18
- package/dist/pages/address-list/ChooseContact.js +50 -78
- package/dist/pages/address-list/Icons.js +7 -14
- package/dist/pages/address-list/Organization.js +59 -89
- package/dist/pages/address-list/UserDetail.js +55 -83
- package/dist/pages/address-list/UserJobs.js +31 -33
- package/dist/pages/address-list/UserSearch.js +29 -54
- package/dist/pages/address-list/addressList.routes.js +11 -16
- package/dist/pages/collection/Collection.js +53 -81
- package/dist/pages/collection/ContentFactory.js +53 -82
- package/dist/pages/collection/collection.routes.js +3 -9
- package/dist/pages/conversation/ForwardToConversation.js +63 -91
- package/dist/pages/conversation/List.js +74 -102
- package/dist/pages/conversation/components/ConversationCard.js +46 -74
- package/dist/pages/conversation/components/ConversationOption.js +27 -55
- package/dist/pages/conversation/conversation.routes.js +17 -23
- package/dist/pages/conversation/setting/GroupTransfer.js +32 -60
- package/dist/pages/conversation/setting/OptionAvatars.js +62 -90
- package/dist/pages/conversation/setting/OptionCancelGroup.js +14 -42
- package/dist/pages/conversation/setting/OptionConversation.js +20 -48
- package/dist/pages/conversation/setting/OptionGroup.js +20 -48
- package/dist/pages/conversation/setting/OptionGroupManage.js +21 -49
- package/dist/pages/conversation/setting/OptionGroupMoreMember.js +48 -53
- package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.js +49 -77
- package/dist/pages/conversation/setting/Setting.js +49 -54
- package/dist/pages/conversation/setting/SettingChatBg.js +26 -54
- package/dist/pages/index.js +7 -27
- package/dist/pages/message/ChooseMember.js +56 -84
- package/dist/pages/message/MessageBackup/Bar.js +18 -43
- package/dist/pages/message/MessageBackup/MessageBackup.js +42 -72
- package/dist/pages/message/MessageBackup/RestoreBackupPage.js +48 -76
- package/dist/pages/message/MessageBackup/StartBackupPage.js +48 -76
- package/dist/pages/message/MessageBackup/index.js +3 -12
- package/dist/pages/message/MessageBackup/utils.js +14 -22
- package/dist/pages/message/MessageList.js +141 -135
- package/dist/pages/message/MessageRecord.js +49 -73
- package/dist/pages/message/components/BusiNotifyCard.js +60 -85
- package/dist/pages/message/components/ChatBg.js +11 -36
- package/dist/pages/message/components/MessageItem.js +82 -110
- package/dist/pages/message/components/MessageItemQuote.js +30 -58
- package/dist/pages/message/components/MessageItemTips.js +27 -55
- package/dist/pages/message/components/MessageOption.js +96 -120
- package/dist/pages/message/components/MessagePayload.js +36 -64
- package/dist/pages/message/components/MessagePictureAlbum.js +32 -60
- package/dist/pages/message/components/MessageReceiptStatus.js +18 -43
- package/dist/pages/message/components/MessageUndo.js +18 -48
- package/dist/pages/message/components/MultipleBar/index.js +48 -76
- package/dist/pages/message/components/Payload/PayloadContact.js +30 -58
- package/dist/pages/message/components/Payload/PayloadFile.js +41 -65
- package/dist/pages/message/components/Payload/PayloadMultiple.js +38 -66
- package/dist/pages/message/components/Payload/PayloadNotify.js +28 -56
- package/dist/pages/message/components/Payload/PayloadPicture.js +21 -49
- package/dist/pages/message/components/Payload/PayloadShare.js +39 -67
- package/dist/pages/message/components/Payload/PayloadText.js +39 -67
- package/dist/pages/message/components/Payload/PayloadVideo.js +28 -56
- package/dist/pages/message/components/Payload/PayloadVoice.js +80 -93
- package/dist/pages/message/components/Payload/PayloadWrapper.js +18 -43
- package/dist/pages/message/components/Payload/type.js +1 -2
- package/dist/pages/message/components/ReceiptBack.js +31 -61
- package/dist/pages/message/components/TextMixMessage.js +13 -38
- package/dist/pages/message/components/TextMixQuote.js +129 -158
- package/dist/pages/message/components/TextMixQuoteMessage.js +16 -44
- package/dist/pages/message/components/UploadProgress.js +12 -37
- package/dist/pages/message/components/messageBar/EmojiPanel.js +25 -50
- package/dist/pages/message/components/messageBar/Icons.js +56 -74
- package/dist/pages/message/components/messageBar/MessageBar.js +84 -115
- package/dist/pages/message/components/messageBar/MessageInput.js +30 -55
- package/dist/pages/message/components/messageBar/OptionPanel.js +54 -82
- package/dist/pages/message/components/messageBar/VoiceBar.js +122 -100
- package/dist/pages/message/components/messageBar/index.js +2 -23
- package/dist/pages/message/message.routes.js +11 -40
- package/dist/pages/search/Search.js +38 -66
- package/dist/pages/search/SearchChatRecords.js +64 -92
- package/dist/pages/search/SearchFile.js +68 -96
- package/dist/pages/search/SearchManager.js +60 -65
- package/dist/pages/search/SearchPicturePage.js +16 -44
- package/dist/pages/search/components/ChatRecords.js +46 -74
- package/dist/pages/search/components/MyGroupChat.js +41 -69
- package/dist/pages/search/components/PictureMulipleBar.js +35 -63
- package/dist/pages/search/components/SearchFileList.js +59 -64
- package/dist/pages/search/components/SearchPictures.js +68 -98
- package/dist/pages/search/components/SearchShareLinkList.js +50 -55
- package/dist/pages/search/components/SearchUser.js +25 -53
- package/dist/pages/search/components/useSearchMessage.js +12 -16
- package/dist/pages/search/search.routes.js +11 -17
- package/dist/pages/search/utils.js +4 -12
- package/dist/pages/types.js +1 -2
- package/dist/slice/contact/contact.action.js +1 -2
- package/dist/slice/contact/contact.slice.js +4 -8
- package/dist/slice/index.js +7 -13
- package/dist/slice/panel/panel.slice.d.ts +2 -1
- package/dist/slice/panel/panel.slice.js +8 -7
- package/dist/slice/video/video.action.d.ts +1 -0
- package/dist/slice/video/video.action.js +56 -38
- package/dist/slice/video/video.slice.d.ts +1 -1
- package/dist/slice/video/video.slice.js +7 -8
- package/dist/utils/audio.d.ts +3 -0
- package/dist/utils/audio.js +10 -0
- package/dist/utils/color.js +2 -9
- package/dist/utils/common-action-sheet.js +9 -14
- package/dist/utils/cookie.js +6 -14
- package/dist/utils/emoji.js +9 -12
- package/dist/utils/file-icon.js +33 -60
- package/dist/utils/file-operate.js +1 -2
- package/dist/utils/file.d.ts +1 -1
- package/dist/utils/file.js +74 -87
- package/dist/utils/golden-rectangle.js +3 -7
- package/dist/utils/phone.js +13 -22
- package/dist/utils/request.js +7 -15
- package/dist/utils/scroll.js +5 -9
- package/dist/utils/summary.js +4 -11
- package/dist/utils/take-camera.js +12 -19
- package/dist/utils/text-mix.js +4 -11
- package/dist/utils/upload.js +20 -41
- package/package.json +6 -7
@@ -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,35 +7,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
8
|
});
|
33
9
|
};
|
34
|
-
|
35
|
-
|
36
|
-
};
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
const im_base_1 = require("@smart-link/im-base");
|
48
|
-
const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
|
49
|
-
const MessagePictureAlbum_1 = __importDefault(require("../../../pages/message/components/MessagePictureAlbum"));
|
50
|
-
const useSearchMessage_1 = require("../../../pages/search/components/useSearchMessage");
|
51
|
-
const video_action_1 = require("../../../slice/video/video.action");
|
10
|
+
import { Dimensions, SectionList, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
11
|
+
import CachedImage from "../../../components/CachedImage";
|
12
|
+
import { Checkbox, dp, Toast, useNavigation } from "@smart-link/rn-ui";
|
13
|
+
import PictureMultipleBar from "./PictureMulipleBar";
|
14
|
+
import React, { useMemo, useState } from "react";
|
15
|
+
import dayjs from "dayjs";
|
16
|
+
import { getImManager } from "../../../init";
|
17
|
+
import { ConfirmActionSheet } from "../../../utils/common-action-sheet";
|
18
|
+
import { ConversationActions, MessageActions, PayloadType } from '@smart-link/im-base';
|
19
|
+
import useTranslation from "../../../hooks/useTranslation";
|
20
|
+
import MessagePictureAlbum from "../../../pages/message/components/MessagePictureAlbum";
|
21
|
+
import { useSearchMessage } from "./useSearchMessage";
|
22
|
+
import { loadVideoPlayer } from "../../../slice/video/video.action";
|
52
23
|
const numColumns = 4;
|
53
|
-
const { width } =
|
54
|
-
const SearchPictures = ({ conversationId, multiple }) => {
|
24
|
+
const { width } = Dimensions.get('window');
|
25
|
+
export const SearchPictures = ({ conversationId, multiple }) => {
|
55
26
|
// 分别获取图片和视频数据
|
56
|
-
const { data: pData, onLoadMore: onLoadMorePictures, reload: reloadPictures, } =
|
27
|
+
const { data: pData, onLoadMore: onLoadMorePictures, reload: reloadPictures, } = useSearchMessage({
|
57
28
|
keyword: '',
|
58
29
|
conversationId,
|
59
30
|
payloadType: 'picture',
|
60
31
|
normalData: false,
|
61
32
|
});
|
62
|
-
const { data: vData, onLoadMore: onLoadMoreVideos, reload: reloadVideos, } =
|
33
|
+
const { data: vData, onLoadMore: onLoadMoreVideos, reload: reloadVideos, } = useSearchMessage({
|
63
34
|
keyword: '',
|
64
35
|
conversationId,
|
65
36
|
payloadType: 'video',
|
@@ -96,28 +67,28 @@ const SearchPictures = ({ conversationId, multiple }) => {
|
|
96
67
|
}
|
97
68
|
});
|
98
69
|
// ...其他代码保持不变
|
99
|
-
const [checkedIds, setCheckedIds] =
|
100
|
-
const navigation =
|
101
|
-
const { t } = (
|
102
|
-
const [preview, setPreview] =
|
70
|
+
const [checkedIds, setCheckedIds] = useState([]);
|
71
|
+
const navigation = useNavigation();
|
72
|
+
const { t } = useTranslation();
|
73
|
+
const [preview, setPreview] = useState({
|
103
74
|
visible: false,
|
104
75
|
messageSeq: '',
|
105
76
|
messages: []
|
106
77
|
});
|
107
|
-
const sectionList =
|
78
|
+
const sectionList = useMemo(() => {
|
108
79
|
const mapData = {};
|
109
|
-
const thisWeek = (
|
110
|
-
const thisMonth = (
|
80
|
+
const thisWeek = dayjs().startOf('week');
|
81
|
+
const thisMonth = dayjs().startOf('month');
|
111
82
|
data.forEach((item, index) => {
|
112
83
|
let date = '';
|
113
|
-
if ((
|
84
|
+
if (dayjs(item.messageTime).isSame(thisWeek, 'week')) {
|
114
85
|
date = 'thisWeek';
|
115
86
|
}
|
116
|
-
else if ((
|
87
|
+
else if (dayjs(item.messageTime).isSame(thisMonth, 'month')) {
|
117
88
|
date = 'thisMonth';
|
118
89
|
}
|
119
90
|
else {
|
120
|
-
date = (
|
91
|
+
date = dayjs(item.messageTime).format('YYYY-MM');
|
121
92
|
}
|
122
93
|
if (mapData[date]) {
|
123
94
|
mapData[date].push(item);
|
@@ -142,41 +113,41 @@ const SearchPictures = ({ conversationId, multiple }) => {
|
|
142
113
|
}, [data]);
|
143
114
|
const onPicMultipleForward = () => {
|
144
115
|
const messages = data.filter(item => checkedIds.includes(item.messageSeq));
|
145
|
-
|
116
|
+
getImManager().store.dispatch(MessageActions.setForwardMessage(messages));
|
146
117
|
navigation.navigate('ForwardToConversation');
|
147
118
|
// setMultiple(false);
|
148
119
|
setCheckedIds([]);
|
149
120
|
};
|
150
121
|
const onPicMultipleCollect = () => __awaiter(void 0, void 0, void 0, function* () {
|
151
122
|
const messages = data.filter(item => checkedIds.includes(item.messageSeq));
|
152
|
-
const imManager =
|
123
|
+
const imManager = getImManager();
|
153
124
|
for (let i = 0; i < messages.length; i++) {
|
154
|
-
yield imManager.store.dispatch(
|
125
|
+
yield imManager.store.dispatch(MessageActions.collectMessage(imManager, messages[i]));
|
155
126
|
}
|
156
|
-
|
127
|
+
Toast.success(t('collectSuccess'));
|
157
128
|
// setMultiple(false);
|
158
129
|
setCheckedIds([]);
|
159
130
|
});
|
160
131
|
const onPicMultipleDelete = () => {
|
161
|
-
const imManager =
|
162
|
-
|
132
|
+
const imManager = getImManager();
|
133
|
+
ConfirmActionSheet(t('confirmDeletePictures'), () => __awaiter(void 0, void 0, void 0, function* () {
|
163
134
|
const updateData = {
|
164
135
|
id: conversationId,
|
165
136
|
errorText: '',
|
166
137
|
text: t('userDeleteMessage', { count: checkedIds.length }),
|
167
138
|
};
|
168
139
|
yield imManager.db.updateConversationById(updateData);
|
169
|
-
imManager.store.dispatch(
|
140
|
+
imManager.store.dispatch(ConversationActions.updateConversation(updateData));
|
170
141
|
// 需要更新消息列表
|
171
|
-
imManager.store.dispatch(
|
142
|
+
imManager.store.dispatch(MessageActions.deleteMessages(checkedIds));
|
172
143
|
yield imManager.db.deleteMessageByPKBatch(checkedIds);
|
173
144
|
yield imManager.db.deleteMessageEmittingByPKBatch(checkedIds);
|
174
145
|
reload();
|
175
|
-
|
146
|
+
Toast.success(t('deleteSuccess'));
|
176
147
|
}), t);
|
177
148
|
};
|
178
|
-
return (<
|
179
|
-
<
|
149
|
+
return (<View style={{ flex: 1 }}>
|
150
|
+
<SectionList style={{ flex: 1 }} sections={sectionList} keyExtractor={item => item.key} renderSectionHeader={({ section: { title } }) => {
|
180
151
|
let date = '';
|
181
152
|
if (title === 'thisWeek') {
|
182
153
|
date = t('thisWeek');
|
@@ -187,13 +158,13 @@ const SearchPictures = ({ conversationId, multiple }) => {
|
|
187
158
|
else {
|
188
159
|
date = title;
|
189
160
|
}
|
190
|
-
return (<
|
191
|
-
<
|
192
|
-
</
|
161
|
+
return (<View style={styles.header}>
|
162
|
+
<Text style={styles.headerText}>{date}</Text>
|
163
|
+
</View>);
|
193
164
|
}} renderItem={({ item }) => {
|
194
|
-
return (<
|
195
|
-
{item.subList.map(message => (<
|
196
|
-
<
|
165
|
+
return (<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
166
|
+
{item.subList.map(message => (<View key={message.messageSeq} style={styles.item}>
|
167
|
+
<TouchableOpacity onPress={() => {
|
197
168
|
if (multiple) {
|
198
169
|
setCheckedIds(prev => {
|
199
170
|
if (prev.includes(message.messageSeq)) {
|
@@ -206,7 +177,7 @@ const SearchPictures = ({ conversationId, multiple }) => {
|
|
206
177
|
}
|
207
178
|
else {
|
208
179
|
// 根据类型处理预览
|
209
|
-
if (message.payloadType ===
|
180
|
+
if (message.payloadType === PayloadType.PICTURE) {
|
210
181
|
// 预览图片
|
211
182
|
setPreview({
|
212
183
|
visible: true,
|
@@ -214,9 +185,9 @@ const SearchPictures = ({ conversationId, multiple }) => {
|
|
214
185
|
messageSeq: message.messageSeq
|
215
186
|
});
|
216
187
|
}
|
217
|
-
else if (message.payloadType ===
|
188
|
+
else if (message.payloadType === PayloadType.VIDEO) {
|
218
189
|
// 播放视频
|
219
|
-
|
190
|
+
getImManager().store.dispatch(loadVideoPlayer({
|
220
191
|
messageSeq: message.messageSeq,
|
221
192
|
payload: message.payload
|
222
193
|
}));
|
@@ -224,39 +195,38 @@ const SearchPictures = ({ conversationId, multiple }) => {
|
|
224
195
|
}
|
225
196
|
}}>
|
226
197
|
{/* 媒体内容容器 */}
|
227
|
-
<
|
228
|
-
{message.payloadType ===
|
198
|
+
<View style={styles.mediaContainer}>
|
199
|
+
{message.payloadType === PayloadType.PICTURE ? (
|
229
200
|
// 图片展示
|
230
|
-
<
|
201
|
+
<CachedImage style={styles.img} localPath={message.payload.localPath} fileId={message.payload.fileId}/>) : (
|
231
202
|
// 视频展示
|
232
203
|
<>
|
233
|
-
<
|
204
|
+
<CachedImage style={styles.img} localPath={message.payload.localPath} fileId={message.payload.fileId}/>
|
234
205
|
{/* 视频播放图标 */}
|
235
|
-
<
|
236
|
-
<
|
237
|
-
</
|
206
|
+
<View style={styles.playIcon}>
|
207
|
+
<Text style={styles.playIconText}>▶</Text>
|
208
|
+
</View>
|
238
209
|
</>)}
|
239
|
-
</
|
240
|
-
</
|
241
|
-
<
|
242
|
-
{multiple && (<
|
243
|
-
</
|
244
|
-
</
|
245
|
-
</
|
210
|
+
</View>
|
211
|
+
</TouchableOpacity>
|
212
|
+
<View style={styles.checkbox}>
|
213
|
+
{multiple && (<Checkbox style={{ pointerEvents: 'none' }} checked={checkedIds.includes(message.messageSeq)} size='s'/>)}
|
214
|
+
</View>
|
215
|
+
</View>))}
|
216
|
+
</View>);
|
246
217
|
}} onEndReachedThreshold={0.1} onEndReached={onLoadMore}/>
|
247
|
-
{multiple && <
|
218
|
+
{multiple && <PictureMultipleBar disabled={!checkedIds.length} onPicMultipleForward={onPicMultipleForward} onPicMultipleCollect={onPicMultipleCollect} onPicMultipleDelete={onPicMultipleDelete}/>}
|
248
219
|
|
249
|
-
<
|
220
|
+
<MessagePictureAlbum visible={preview.visible} messages={preview.messages} messageSeq={preview.messageSeq} onClose={() => {
|
250
221
|
setPreview({ visible: false, messageSeq: '', messages: [] });
|
251
222
|
}}/>
|
252
|
-
</
|
223
|
+
</View>);
|
253
224
|
};
|
254
|
-
|
255
|
-
const styles = react_native_1.StyleSheet.create({
|
225
|
+
const styles = StyleSheet.create({
|
256
226
|
header: {
|
257
227
|
width: '100%',
|
258
|
-
height:
|
259
|
-
paddingLeft:
|
228
|
+
height: dp(22),
|
229
|
+
paddingLeft: dp(4),
|
260
230
|
justifyContent: 'center',
|
261
231
|
backgroundColor: 'rgba(255, 255, 255, 0.6)',
|
262
232
|
},
|
@@ -302,4 +272,4 @@ const styles = react_native_1.StyleSheet.create({
|
|
302
272
|
marginLeft: 2, // 让播放图标稍微右移,看起来更居中
|
303
273
|
},
|
304
274
|
});
|
305
|
-
|
275
|
+
export default SearchPictures;
|
@@ -1,59 +1,54 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
11
|
-
const react_1 = require("react");
|
12
|
-
const Favicon_1 = __importDefault(require("../../../components/Favicon"));
|
13
|
-
const useSearchMessage_1 = require("./useSearchMessage");
|
14
|
-
const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
|
1
|
+
import { borderStyle } from "../../../components/styles";
|
2
|
+
import { dp } from '@smart-link/rn-ui';
|
3
|
+
import { PixelRatio, SectionList, TouchableOpacity, View, Text, StyleSheet, Linking } from "react-native";
|
4
|
+
import ChatAvatar from "../../../components/ChatAvatar";
|
5
|
+
import dayjs from "dayjs";
|
6
|
+
import { memo } from "react";
|
7
|
+
import Favicon from "../../../components/Favicon";
|
8
|
+
import { useSearchMessage } from "./useSearchMessage";
|
9
|
+
import useTranslation from "../../../hooks/useTranslation";
|
15
10
|
const backgroundColor = '#fff';
|
16
|
-
const size =
|
11
|
+
const size = dp(45);
|
17
12
|
const SearchShareLinkList = ({ keyword, conversationId }) => {
|
18
|
-
const { t } = (
|
19
|
-
const { data, onLoadMore } =
|
13
|
+
const { t } = useTranslation();
|
14
|
+
const { data, onLoadMore } = useSearchMessage({
|
20
15
|
conversationId,
|
21
16
|
keyword,
|
22
17
|
payloadType: 'share',
|
23
18
|
});
|
24
19
|
if (data.length === 0) {
|
25
|
-
return <
|
26
|
-
<
|
27
|
-
</
|
20
|
+
return <View style={styles.empty}>
|
21
|
+
<Text>{t('noSearchResult')}</Text>
|
22
|
+
</View>;
|
28
23
|
}
|
29
24
|
const keyExtractor = (item) => item.messageSeq;
|
30
25
|
const renderSectionHeader = ({ section }) => {
|
31
|
-
return (<
|
26
|
+
return (<Text style={styles.dateTxt}>{section.date}</Text>);
|
32
27
|
};
|
33
28
|
const renderItem = ({ item }) => {
|
34
29
|
const { messageFrom, messageFromName, payload = {}, } = item;
|
35
|
-
return (<
|
30
|
+
return (<TouchableOpacity style={[styles.item, { backgroundColor }]} activeOpacity={0.5} onPress={() => {
|
36
31
|
if (payload.url) {
|
37
|
-
|
32
|
+
Linking.openURL(payload.url);
|
38
33
|
}
|
39
34
|
}}>
|
40
|
-
<
|
41
|
-
<
|
42
|
-
<
|
43
|
-
<
|
44
|
-
</
|
45
|
-
<
|
46
|
-
<
|
47
|
-
<
|
48
|
-
<
|
49
|
-
</
|
50
|
-
<
|
51
|
-
</
|
52
|
-
</
|
35
|
+
<View style={styles.itemTop}>
|
36
|
+
<ChatAvatar disabled={true} id={messageFrom} name={messageFromName} size={dp(24)}/>
|
37
|
+
<Text style={styles.name} numberOfLines={1}>{messageFromName}</Text>
|
38
|
+
<Text style={styles.time}>{dayjs(item.messageTime).format("YYYY-MM-DD")}</Text>
|
39
|
+
</View>
|
40
|
+
<View style={styles.link}>
|
41
|
+
<View style={styles.linkInfo}>
|
42
|
+
<Text style={styles.title} numberOfLines={1} ellipsizeMode={'middle'}>{payload.title || payload.description}</Text>
|
43
|
+
<Text style={styles.description} numberOfLines={2} ellipsizeMode={'middle'}>{payload.description}</Text>
|
44
|
+
</View>
|
45
|
+
<Favicon url={payload.url} size={size}/>
|
46
|
+
</View>
|
47
|
+
</TouchableOpacity>);
|
53
48
|
};
|
54
|
-
return (<
|
49
|
+
return (<SectionList style={styles.view} sections={data} renderItem={renderItem} renderSectionHeader={renderSectionHeader} keyExtractor={keyExtractor} initialNumToRender={10} progressViewOffset={100} onEndReached={onLoadMore} onEndReachedThreshold={0.2}/>);
|
55
50
|
};
|
56
|
-
const styles =
|
51
|
+
const styles = StyleSheet.create({
|
57
52
|
view: {
|
58
53
|
backgroundColor: "#F5F5F5"
|
59
54
|
},
|
@@ -63,15 +58,15 @@ const styles = react_native_1.StyleSheet.create({
|
|
63
58
|
justifyContent: 'center'
|
64
59
|
},
|
65
60
|
dateTxt: {
|
66
|
-
paddingVertical:
|
67
|
-
paddingHorizontal:
|
68
|
-
marginBottom:
|
69
|
-
borderTopWidth: 1 /
|
70
|
-
borderBottomWidth: 1 /
|
61
|
+
paddingVertical: dp(5),
|
62
|
+
paddingHorizontal: dp(12),
|
63
|
+
marginBottom: dp(5),
|
64
|
+
borderTopWidth: 1 / PixelRatio.get(),
|
65
|
+
borderBottomWidth: 1 / PixelRatio.get(),
|
71
66
|
borderColor: "#E3E3E3",
|
72
67
|
backgroundColor: "#EDEDED"
|
73
68
|
},
|
74
|
-
item: Object.assign(Object.assign({ marginBottom:
|
69
|
+
item: Object.assign(Object.assign({ marginBottom: dp(5), marginHorizontal: dp(12), paddingVertical: dp(12), paddingHorizontal: dp(20) }, borderStyle), { borderWidth: 0 }),
|
75
70
|
itemTop: {
|
76
71
|
flex: 1,
|
77
72
|
flexDirection: "row",
|
@@ -79,34 +74,34 @@ const styles = react_native_1.StyleSheet.create({
|
|
79
74
|
position: "relative"
|
80
75
|
},
|
81
76
|
name: {
|
82
|
-
paddingLeft:
|
77
|
+
paddingLeft: dp(10)
|
83
78
|
},
|
84
79
|
time: {
|
85
80
|
position: "absolute",
|
86
|
-
top:
|
81
|
+
top: dp(5),
|
87
82
|
right: 0,
|
88
|
-
fontSize:
|
83
|
+
fontSize: dp(12),
|
89
84
|
color: '#a2a2a2'
|
90
85
|
},
|
91
86
|
link: {
|
92
87
|
flexDirection: 'row',
|
93
|
-
marginTop:
|
88
|
+
marginTop: dp(10)
|
94
89
|
},
|
95
90
|
linkInfo: {
|
96
91
|
flex: 1,
|
97
|
-
paddingRight:
|
92
|
+
paddingRight: dp(10),
|
98
93
|
justifyContent: 'center'
|
99
94
|
},
|
100
95
|
title: {
|
101
|
-
fontSize:
|
102
|
-
lineHeight:
|
96
|
+
fontSize: dp(15),
|
97
|
+
lineHeight: dp(20),
|
103
98
|
color: '#010101'
|
104
99
|
},
|
105
100
|
description: {
|
106
|
-
marginTop:
|
107
|
-
fontSize:
|
108
|
-
lineHeight:
|
101
|
+
marginTop: dp(5),
|
102
|
+
fontSize: dp(12),
|
103
|
+
lineHeight: dp(14),
|
109
104
|
color: '#a2a2a2'
|
110
105
|
},
|
111
106
|
});
|
112
|
-
|
107
|
+
export default memo(SearchShareLinkList);
|
@@ -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,53 +7,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
8
|
});
|
33
9
|
};
|
34
|
-
|
35
|
-
|
36
|
-
};
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
const ChatAvatar_1 = __importDefault(require("../../../components/ChatAvatar/ChatAvatar"));
|
43
|
-
const Highlighter_1 = __importDefault(require("../../../components/Highlighter"));
|
44
|
-
const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
|
45
|
-
const init_1 = require("../../../init");
|
10
|
+
import { dp, ListRow, useNavigation } from '@smart-link/rn-ui';
|
11
|
+
import React, { memo, useEffect, useState } from 'react';
|
12
|
+
import { ScrollView, Text, View } from 'react-native';
|
13
|
+
import { searchUser } from '../../../api/user';
|
14
|
+
import ChatAvatar from '../../../components/ChatAvatar/ChatAvatar';
|
15
|
+
import Highlighter from '../../../components/Highlighter';
|
16
|
+
import useTranslation from '../../../hooks/useTranslation';
|
17
|
+
import { getImManager } from '../../../init';
|
46
18
|
const RenderUserItem = (props) => {
|
47
|
-
return (<
|
48
|
-
<
|
49
|
-
<
|
50
|
-
</
|
19
|
+
return (<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
20
|
+
<ChatAvatar priority="outside" id={props.data.userId} url={props.data.avatars} name={props.data.userName}/>
|
21
|
+
<Highlighter style={{ marginLeft: dp(10), flex: 1 }} searchWord={props.keyword} textToHighlight={props.data.userName}/>
|
22
|
+
</View>);
|
51
23
|
};
|
52
24
|
const SearchUser = ({ keyword }) => {
|
53
|
-
const navigation =
|
54
|
-
const { t } = (
|
55
|
-
const [userList, setUserList] =
|
56
|
-
|
25
|
+
const navigation = useNavigation();
|
26
|
+
const { t } = useTranslation();
|
27
|
+
const [userList, setUserList] = useState([]);
|
28
|
+
useEffect(() => {
|
57
29
|
if (!keyword || keyword === '') {
|
58
30
|
return;
|
59
31
|
}
|
60
|
-
|
32
|
+
searchUser({
|
61
33
|
searchKey: keyword,
|
62
34
|
}).then(({ data }) => {
|
63
35
|
setUserList(data);
|
64
36
|
});
|
65
37
|
}, [keyword]);
|
66
38
|
if (userList.length === 0) {
|
67
|
-
return (<
|
39
|
+
return (<View style={{
|
68
40
|
flex: 1,
|
69
41
|
justifyContent: 'center',
|
70
42
|
alignItems: 'center',
|
71
43
|
}}>
|
72
|
-
<
|
73
|
-
</
|
44
|
+
<Text>{t('noSearchResult')}</Text>
|
45
|
+
</View>);
|
74
46
|
}
|
75
|
-
return (<
|
76
|
-
{userList.map((item) => (<
|
47
|
+
return (<ScrollView style={{ flex: 1 }}>
|
48
|
+
{userList.map((item) => (<ListRow key={item.userId} onPress={() => __awaiter(void 0, void 0, void 0, function* () {
|
77
49
|
console.log('item', item);
|
78
|
-
yield
|
50
|
+
yield getImManager().initUserConversation(item);
|
79
51
|
navigation.navigate('MessageList');
|
80
52
|
})} title={<RenderUserItem keyword={keyword} data={item}/>} topSeparator="full"/>))}
|
81
|
-
</
|
53
|
+
</ScrollView>);
|
82
54
|
};
|
83
|
-
|
55
|
+
export default memo(SearchUser);
|
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -8,17 +7,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
8
|
});
|
10
9
|
};
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
const
|
16
|
-
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
20
|
-
const noMore = (0, react_1.useRef)(false);
|
21
|
-
const reloadFlag = (0, react_1.useRef)(false);
|
10
|
+
import { getImManager } from "../../../init";
|
11
|
+
import { useEffect, useRef, useState } from "react";
|
12
|
+
import { normalFilesData } from "../../../pages/search/utils";
|
13
|
+
export function useSearchMessage({ conversationId, payloadType, keyword, normalData = true }) {
|
14
|
+
const imManager = getImManager();
|
15
|
+
const [data, setData] = useState([]);
|
16
|
+
const fileOffset = useRef(0);
|
17
|
+
const noMore = useRef(false);
|
18
|
+
const reloadFlag = useRef(false);
|
22
19
|
const loadSearch = () => __awaiter(this, void 0, void 0, function* () {
|
23
20
|
if (noMore.current)
|
24
21
|
return;
|
@@ -45,9 +42,9 @@ function useSearchMessage({ conversationId, payloadType, keyword, normalData = t
|
|
45
42
|
setData(prevState => {
|
46
43
|
if (reloadFlag.current) {
|
47
44
|
reloadFlag.current = false;
|
48
|
-
return normalData ?
|
45
|
+
return normalData ? normalFilesData([], tList) : tList;
|
49
46
|
}
|
50
|
-
return normalData ?
|
47
|
+
return normalData ? normalFilesData(prevState, tList) : prevState.concat(tList);
|
51
48
|
});
|
52
49
|
});
|
53
50
|
const reload = () => {
|
@@ -56,7 +53,7 @@ function useSearchMessage({ conversationId, payloadType, keyword, normalData = t
|
|
56
53
|
reloadFlag.current = true;
|
57
54
|
loadSearch();
|
58
55
|
};
|
59
|
-
|
56
|
+
useEffect(() => {
|
60
57
|
reload();
|
61
58
|
}, [keyword, conversationId]);
|
62
59
|
return {
|
@@ -65,4 +62,3 @@ function useSearchMessage({ conversationId, payloadType, keyword, normalData = t
|
|
65
62
|
reload
|
66
63
|
};
|
67
64
|
}
|
68
|
-
exports.useSearchMessage = useSearchMessage;
|