@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,33 +7,29 @@ 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
|
-
const
|
45
|
-
const
|
46
|
-
const
|
47
|
-
const
|
48
|
-
const
|
49
|
-
const
|
50
|
-
const { params } = (0, native_1.useRoute)();
|
51
|
-
const [keyword, setKeyword] = (0, react_1.useState)(params.keyword || '');
|
52
|
-
const { t } = (0, useTranslation_1.default)();
|
53
|
-
const theme = (0, rn_ui_1.useTheme)();
|
10
|
+
import { NavigationPage, WrappedSearchPage, dp, useTheme, useNavigation, HeaderSearchBar } from '@smart-link/rn-ui';
|
11
|
+
import React, { memo, useEffect, useState } from 'react';
|
12
|
+
import { Text, View, StyleSheet, TouchableOpacity, FlatList } from 'react-native';
|
13
|
+
import useTranslation from '../../hooks/useTranslation';
|
14
|
+
import { getImManager } from '../../init';
|
15
|
+
import { useRoute } from '@react-navigation/native';
|
16
|
+
import { buildSearchText } from '@smart-link/im-base';
|
17
|
+
import ChatAvatar from '../../components/ChatAvatar/ChatAvatar';
|
18
|
+
import { getSummary } from '../../utils/summary';
|
19
|
+
import FormatTimeText from '../../components/FormatTimeText';
|
20
|
+
const SearchChatRecords = memo(() => {
|
21
|
+
const navigation = useNavigation();
|
22
|
+
const { params } = useRoute();
|
23
|
+
const [keyword, setKeyword] = useState(params.keyword || '');
|
24
|
+
const { t } = useTranslation();
|
25
|
+
const theme = useTheme();
|
54
26
|
const { name, id } = params.conversation;
|
55
|
-
const [messages, setMessages] =
|
56
|
-
|
27
|
+
const [messages, setMessages] = useState([]);
|
28
|
+
useEffect(() => {
|
57
29
|
if (!keyword)
|
58
30
|
return;
|
59
31
|
console.log('keyword', keyword, params.conversation.id);
|
60
|
-
|
32
|
+
getImManager()
|
61
33
|
.db.searchMessages({
|
62
34
|
conversationId: params.conversation.id,
|
63
35
|
keyword,
|
@@ -67,47 +39,47 @@ const SearchChatRecords = (0, react_1.memo)(() => {
|
|
67
39
|
});
|
68
40
|
}, [keyword]);
|
69
41
|
const listHeaderComponent = (<>
|
70
|
-
<
|
71
|
-
<
|
72
|
-
</
|
73
|
-
<
|
42
|
+
<View style={styles.currChat}>
|
43
|
+
<Text style={styles.currChatText}>{'"' + name + '"' + t('searchMsgRec')}</Text>
|
44
|
+
</View>
|
45
|
+
<View style={styles.listHeaderLine}/>
|
74
46
|
</>);
|
75
47
|
const keyExtractor = (item) => item.messageSeq;
|
76
48
|
const renderItem = ({ item }) => {
|
77
49
|
const { messageSeq, messageFrom, messageFromName, messageTime, payload, } = item;
|
78
|
-
return (<
|
79
|
-
yield
|
50
|
+
return (<TouchableOpacity style={styles.item} activeOpacity={0.5} onPress={() => __awaiter(void 0, void 0, void 0, function* () {
|
51
|
+
yield getImManager().initSearchConversation(id, messageSeq);
|
80
52
|
navigation.navigate('MessageList');
|
81
53
|
})}>
|
82
|
-
<
|
83
|
-
<
|
54
|
+
<ChatAvatar id={messageFrom} url={payload.avatars} name={messageFromName} size={dp(42)}/>
|
55
|
+
<View style={styles.width10}/>
|
84
56
|
|
85
|
-
<
|
86
|
-
<
|
87
|
-
<
|
88
|
-
</
|
89
|
-
<
|
90
|
-
</
|
57
|
+
<View style={styles.left}>
|
58
|
+
<Text style={styles.name} numberOfLines={1}>{messageFromName}</Text>
|
59
|
+
<Text style={styles.text} numberOfLines={1}>{getSummary(buildSearchText(item), keyword, 28, theme.primaryColor)}</Text>
|
60
|
+
</View>
|
61
|
+
<FormatTimeText style={styles.time} time={messageTime}/>
|
62
|
+
</TouchableOpacity>);
|
91
63
|
};
|
92
|
-
const itemSeparatorComponent = () => <
|
64
|
+
const itemSeparatorComponent = () => <View style={styles.separator}/>;
|
93
65
|
return (<>
|
94
|
-
<
|
95
|
-
<
|
96
|
-
{messages.length === 0 && (<
|
97
|
-
<
|
66
|
+
<HeaderSearchBar value={keyword} onSubmitEditing={setKeyword}/>
|
67
|
+
<NavigationPage noPadding>
|
68
|
+
{messages.length === 0 && (<View style={{ flex: 1 }}>
|
69
|
+
<View style={{
|
98
70
|
flex: 1,
|
99
71
|
justifyContent: 'center',
|
100
72
|
alignItems: 'center',
|
101
73
|
}}>
|
102
|
-
<
|
103
|
-
</
|
104
|
-
</
|
105
|
-
{messages.length > 0 && (<
|
106
|
-
</
|
74
|
+
<Text>{t('noSearchResult')}</Text>
|
75
|
+
</View>
|
76
|
+
</View>)}
|
77
|
+
{messages.length > 0 && (<FlatList contentContainerStyle={styles.list} data={messages} numColumns={1} initialNumToRender={1} keyExtractor={keyExtractor} renderItem={renderItem} keyboardShouldPersistTaps={'handled'} ItemSeparatorComponent={itemSeparatorComponent} ListHeaderComponent={listHeaderComponent}/>)}
|
78
|
+
</NavigationPage>
|
107
79
|
|
108
80
|
</>);
|
109
81
|
});
|
110
|
-
const styles =
|
82
|
+
const styles = StyleSheet.create({
|
111
83
|
empty: {
|
112
84
|
flex: 1,
|
113
85
|
alignItems: 'center',
|
@@ -115,59 +87,59 @@ const styles = react_native_1.StyleSheet.create({
|
|
115
87
|
},
|
116
88
|
list: {
|
117
89
|
backgroundColor: '#fff',
|
118
|
-
borderWidth:
|
90
|
+
borderWidth: dp(1),
|
119
91
|
borderStyle: 'solid',
|
120
92
|
borderColor: '#eee',
|
121
93
|
borderLeftWidth: 0,
|
122
94
|
borderRightWidth: 0,
|
123
95
|
},
|
124
96
|
item: {
|
125
|
-
paddingHorizontal:
|
126
|
-
paddingVertical:
|
97
|
+
paddingHorizontal: dp(15),
|
98
|
+
paddingVertical: dp(15),
|
127
99
|
flexDirection: 'row',
|
128
100
|
},
|
129
101
|
width10: {
|
130
|
-
width:
|
102
|
+
width: dp(10),
|
131
103
|
},
|
132
104
|
left: {
|
133
105
|
justifyContent: 'space-between',
|
134
106
|
},
|
135
107
|
name: {
|
136
|
-
width:
|
137
|
-
fontSize:
|
138
|
-
lineHeight:
|
108
|
+
width: dp(250),
|
109
|
+
fontSize: dp(13),
|
110
|
+
lineHeight: dp(15),
|
139
111
|
color: '#999',
|
140
112
|
},
|
141
113
|
time: {
|
142
|
-
fontSize:
|
143
|
-
lineHeight:
|
114
|
+
fontSize: dp(13),
|
115
|
+
lineHeight: dp(15),
|
144
116
|
color: '#999',
|
145
117
|
position: 'absolute',
|
146
|
-
top:
|
147
|
-
right:
|
118
|
+
top: dp(10),
|
119
|
+
right: dp(15),
|
148
120
|
},
|
149
121
|
text: {
|
150
|
-
width:
|
151
|
-
fontSize:
|
152
|
-
lineHeight:
|
122
|
+
width: dp(270),
|
123
|
+
fontSize: dp(14),
|
124
|
+
lineHeight: dp(16),
|
153
125
|
color: '#333',
|
154
126
|
},
|
155
127
|
separator: {
|
156
|
-
marginLeft:
|
157
|
-
height:
|
128
|
+
marginLeft: dp(66),
|
129
|
+
height: dp(1),
|
158
130
|
backgroundColor: '#eee',
|
159
131
|
},
|
160
132
|
currChat: {
|
161
133
|
backgroundColor: '#f3f3f3',
|
162
|
-
paddingHorizontal:
|
163
|
-
paddingVertical:
|
134
|
+
paddingHorizontal: dp(15),
|
135
|
+
paddingVertical: dp(8),
|
164
136
|
},
|
165
137
|
currChatText: {
|
166
138
|
color: '#999',
|
167
139
|
},
|
168
140
|
listHeaderLine: {
|
169
|
-
height:
|
141
|
+
height: dp(1),
|
170
142
|
backgroundColor: '#ececec',
|
171
143
|
},
|
172
144
|
});
|
173
|
-
|
145
|
+
export default WrappedSearchPage(SearchChatRecords);
|
@@ -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,27 +7,23 @@ 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
|
-
|
48
|
-
const file_icon_1 = require("../../utils/file-icon");
|
49
|
-
const react_native_file_viewer_1 = __importDefault(require("react-native-file-viewer"));
|
50
|
-
const useTranslation_1 = __importDefault(require("../../hooks/useTranslation"));
|
51
|
-
const native_1 = require("@react-navigation/native");
|
10
|
+
import React, { memo, useEffect, useRef, useState } from 'react';
|
11
|
+
import { View, StyleSheet, PixelRatio, TouchableOpacity, Text, SectionList } from 'react-native';
|
12
|
+
import { dp, HeaderSearchBar, NavigationPage } from '@smart-link/rn-ui';
|
13
|
+
import { borderStyle } from '../../components/styles';
|
14
|
+
import { getImManager } from '../../init';
|
15
|
+
import { MessageActions } from '@smart-link/im-base';
|
16
|
+
import dayjs from 'dayjs';
|
17
|
+
import ChatAvatar from '../../components/ChatAvatar/ChatAvatar';
|
18
|
+
import { numberToFileSize } from '../../utils/file';
|
19
|
+
import FormatTimeText from '../../components/FormatTimeText';
|
20
|
+
import { findSvgIcon } from '../../utils/file-icon';
|
21
|
+
import FileViewer from 'react-native-file-viewer';
|
22
|
+
import useTranslation from '../../hooks/useTranslation';
|
23
|
+
import { useRoute } from '@react-navigation/native';
|
52
24
|
function groupByDate(messages) {
|
53
25
|
const groups = messages.reduce((groups, message) => {
|
54
|
-
const date = (
|
26
|
+
const date = dayjs(message.messageTime).format('YYYY/MM');
|
55
27
|
if (!groups[date]) {
|
56
28
|
groups[date] = [];
|
57
29
|
}
|
@@ -65,14 +37,14 @@ function groupByDate(messages) {
|
|
65
37
|
};
|
66
38
|
});
|
67
39
|
}
|
68
|
-
const SearchFile =
|
69
|
-
const { params } =
|
70
|
-
const { t } = (
|
71
|
-
const [keyword, setKeyword] =
|
72
|
-
const [files, setFiles] =
|
73
|
-
const cacheResults =
|
74
|
-
const pageNum =
|
75
|
-
const imManager =
|
40
|
+
const SearchFile = memo(() => {
|
41
|
+
const { params } = useRoute();
|
42
|
+
const { t } = useTranslation();
|
43
|
+
const [keyword, setKeyword] = useState('');
|
44
|
+
const [files, setFiles] = useState([]);
|
45
|
+
const cacheResults = useRef([]);
|
46
|
+
const pageNum = useRef(0);
|
47
|
+
const imManager = getImManager();
|
76
48
|
const loadSearchFiles = (keyword = '') => __awaiter(void 0, void 0, void 0, function* () {
|
77
49
|
const tFiles = yield imManager.db.searchMessages({
|
78
50
|
keyword: keyword,
|
@@ -88,7 +60,7 @@ const SearchFile = (0, react_1.memo)(() => {
|
|
88
60
|
const groups = groupByDate(cacheResults.current);
|
89
61
|
setFiles(groups);
|
90
62
|
});
|
91
|
-
|
63
|
+
useEffect(() => {
|
92
64
|
pageNum.current = 0;
|
93
65
|
cacheResults.current = [];
|
94
66
|
loadSearchFiles(keyword);
|
@@ -96,8 +68,8 @@ const SearchFile = (0, react_1.memo)(() => {
|
|
96
68
|
const renderItem = ({ item }) => {
|
97
69
|
const { messageFrom, messageFromName, payload = {} } = item;
|
98
70
|
const ext = payload.filename.split('.').pop();
|
99
|
-
const Icon =
|
100
|
-
return (<
|
71
|
+
const Icon = findSvgIcon(ext);
|
72
|
+
return (<TouchableOpacity style={[styles.item, { backgroundColor: '#fff' }]} activeOpacity={0.5} onPress={() => __awaiter(void 0, void 0, void 0, function* () {
|
101
73
|
if (!payload.localPath) {
|
102
74
|
payload.localPath = yield imManager.download({
|
103
75
|
fileId: item.payload.fileId,
|
@@ -108,42 +80,42 @@ const SearchFile = (0, react_1.memo)(() => {
|
|
108
80
|
messageSeq: item.messageSeq,
|
109
81
|
payload: payload,
|
110
82
|
});
|
111
|
-
imManager.store.dispatch(
|
83
|
+
imManager.store.dispatch(MessageActions.updateMessage(item.messageSeq, {
|
112
84
|
payload: payload,
|
113
85
|
}));
|
114
86
|
}
|
115
|
-
|
87
|
+
FileViewer.open(payload.localPath);
|
116
88
|
})}>
|
117
|
-
<
|
118
|
-
<
|
119
|
-
<
|
89
|
+
<View style={styles.itemTop}>
|
90
|
+
<ChatAvatar disabled={true} name={messageFromName} id={messageFrom} size={dp(24)}/>
|
91
|
+
<Text style={styles.name} numberOfLines={1}>
|
120
92
|
{messageFromName}
|
121
|
-
</
|
122
|
-
<
|
123
|
-
</
|
124
|
-
<
|
125
|
-
<
|
126
|
-
<
|
93
|
+
</Text>
|
94
|
+
<FormatTimeText style={styles.time} time={item.messageTime}/>
|
95
|
+
</View>
|
96
|
+
<View style={styles.file}>
|
97
|
+
<View style={styles.fileInfo}>
|
98
|
+
<Text style={styles.fileName} numberOfLines={2} ellipsizeMode={'middle'}>
|
127
99
|
{payload.filename}
|
128
|
-
</
|
129
|
-
<
|
130
|
-
</
|
100
|
+
</Text>
|
101
|
+
<Text style={styles.fileSize}>{numberToFileSize(payload.size)}</Text>
|
102
|
+
</View>
|
131
103
|
<Icon style={styles.imageIcon}/>
|
132
|
-
</
|
133
|
-
</
|
104
|
+
</View>
|
105
|
+
</TouchableOpacity>);
|
134
106
|
};
|
135
107
|
return (<>
|
136
|
-
<
|
137
|
-
<
|
138
|
-
{files.length > 0 ? (<
|
139
|
-
return <
|
140
|
-
}} renderItem={renderItem} keyExtractor={item => item.messageSeq} initialNumToRender={10} progressViewOffset={100} onEndReached={() => loadSearchFiles(keyword)} onEndReachedThreshold={0.2}/>) : (<
|
141
|
-
<
|
142
|
-
</
|
143
|
-
</
|
108
|
+
<HeaderSearchBar value={keyword} onSubmitEditing={setKeyword}/>
|
109
|
+
<NavigationPage noPadding>
|
110
|
+
{files.length > 0 ? (<SectionList sections={files} renderSectionHeader={({ section }) => {
|
111
|
+
return <Text style={styles.dateTxt}>{section.date}</Text>;
|
112
|
+
}} renderItem={renderItem} keyExtractor={item => item.messageSeq} initialNumToRender={10} progressViewOffset={100} onEndReached={() => loadSearchFiles(keyword)} onEndReachedThreshold={0.2}/>) : (<View style={styles.empty}>
|
113
|
+
<Text>{t('noSearchResult')}</Text>
|
114
|
+
</View>)}
|
115
|
+
</NavigationPage>
|
144
116
|
</>);
|
145
117
|
});
|
146
|
-
const styles =
|
118
|
+
const styles = StyleSheet.create({
|
147
119
|
view: {},
|
148
120
|
empty: {
|
149
121
|
flex: 1,
|
@@ -151,15 +123,15 @@ const styles = react_native_1.StyleSheet.create({
|
|
151
123
|
justifyContent: 'center',
|
152
124
|
},
|
153
125
|
dateTxt: {
|
154
|
-
paddingVertical:
|
155
|
-
paddingHorizontal:
|
156
|
-
marginBottom:
|
157
|
-
borderTopWidth: 1 /
|
158
|
-
borderBottomWidth: 1 /
|
126
|
+
paddingVertical: dp(5),
|
127
|
+
paddingHorizontal: dp(12),
|
128
|
+
marginBottom: dp(5),
|
129
|
+
borderTopWidth: 1 / PixelRatio.get(),
|
130
|
+
borderBottomWidth: 1 / PixelRatio.get(),
|
159
131
|
borderColor: '#E3E3E3',
|
160
132
|
backgroundColor: '#EDEDED',
|
161
133
|
},
|
162
|
-
item: Object.assign(Object.assign({ marginBottom:
|
134
|
+
item: Object.assign(Object.assign({ marginBottom: dp(5), marginHorizontal: dp(12), paddingVertical: dp(12), paddingHorizontal: dp(20) }, borderStyle), { borderWidth: 0 }),
|
163
135
|
itemTop: {
|
164
136
|
flex: 1,
|
165
137
|
flexDirection: 'row',
|
@@ -167,36 +139,36 @@ const styles = react_native_1.StyleSheet.create({
|
|
167
139
|
position: 'relative',
|
168
140
|
},
|
169
141
|
name: {
|
170
|
-
paddingLeft:
|
142
|
+
paddingLeft: dp(10),
|
171
143
|
},
|
172
144
|
time: {
|
173
145
|
position: 'absolute',
|
174
|
-
top:
|
146
|
+
top: dp(5),
|
175
147
|
right: 0,
|
176
|
-
fontSize:
|
148
|
+
fontSize: dp(12),
|
177
149
|
color: '#a2a2a2',
|
178
150
|
},
|
179
151
|
file: {
|
180
152
|
flexDirection: 'row',
|
181
|
-
marginTop:
|
153
|
+
marginTop: dp(10),
|
182
154
|
},
|
183
155
|
fileInfo: {
|
184
156
|
flex: 1,
|
185
|
-
paddingRight:
|
157
|
+
paddingRight: dp(10),
|
186
158
|
justifyContent: 'center',
|
187
159
|
},
|
188
160
|
fileName: {
|
189
|
-
fontSize:
|
190
|
-
lineHeight:
|
161
|
+
fontSize: dp(15),
|
162
|
+
lineHeight: dp(20),
|
191
163
|
color: '#010101',
|
192
164
|
},
|
193
165
|
fileSize: {
|
194
|
-
fontSize:
|
195
|
-
lineHeight:
|
166
|
+
fontSize: dp(12),
|
167
|
+
lineHeight: dp(20),
|
196
168
|
color: '#a2a2a2',
|
197
169
|
},
|
198
170
|
imageIcon: {
|
199
|
-
height:
|
171
|
+
height: dp(45),
|
200
172
|
},
|
201
173
|
});
|
202
|
-
|
174
|
+
export default SearchFile;
|