@smart-link/rn-im 1.0.22 → 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 +52 -81
- 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 -134
- 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 +7 -11
- 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,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,14 +7,9 @@ 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.MessageRestoreUtils = exports.MessageBackupUtils = void 0;
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
17
|
-
const init_1 = require("../../../init");
|
18
|
-
const backup_1 = require("../../../api/backup");
|
10
|
+
import axios from "axios";
|
11
|
+
import { getImManager } from "../../../init";
|
12
|
+
import { uploadMessage, cancelBackupMessage, queryMyBackMessage, queryMyLastBackupMessageSeq } from "../../../api/backup";
|
19
13
|
class Queue {
|
20
14
|
constructor() {
|
21
15
|
this.queue = [];
|
@@ -96,7 +90,7 @@ class BaseUtils {
|
|
96
90
|
}
|
97
91
|
class TaskItem {
|
98
92
|
constructor(limit, offset) {
|
99
|
-
this.cancelToken =
|
93
|
+
this.cancelToken = axios.CancelToken.source();
|
100
94
|
this.limit = limit;
|
101
95
|
this.offset = offset;
|
102
96
|
}
|
@@ -119,19 +113,19 @@ class BackupTaskItem extends TaskItem {
|
|
119
113
|
}
|
120
114
|
execute(callback, batchId) {
|
121
115
|
return __awaiter(this, void 0, void 0, function* () {
|
122
|
-
const { data, lastMessageSeq } = yield
|
116
|
+
const { data, lastMessageSeq } = yield getImManager().db.selectMessageForBackup({
|
123
117
|
messageSeq: this.messageSeq,
|
124
118
|
limit: this.limit,
|
125
119
|
offset: this.offset
|
126
120
|
});
|
127
121
|
let prevCount = Math.ceil(data.length / 5);
|
128
122
|
callback(prevCount, batchId);
|
129
|
-
const { data: newBatchId } = yield
|
123
|
+
const { data: newBatchId } = yield uploadMessage({ batchId: batchId, lastMessageSeq, messages: data }, { cancelToken: this.cancelToken.token });
|
130
124
|
callback(data.length - prevCount, newBatchId || batchId);
|
131
125
|
});
|
132
126
|
}
|
133
127
|
}
|
134
|
-
class MessageBackupUtils extends BaseUtils {
|
128
|
+
export class MessageBackupUtils extends BaseUtils {
|
135
129
|
constructor(callback) {
|
136
130
|
super(callback);
|
137
131
|
}
|
@@ -146,9 +140,9 @@ class MessageBackupUtils extends BaseUtils {
|
|
146
140
|
return __awaiter(this, void 0, void 0, function* () {
|
147
141
|
this.state = 'running';
|
148
142
|
// 查询最近一次备份的消息序列
|
149
|
-
const { data: messageSeq } = yield
|
143
|
+
const { data: messageSeq } = yield queryMyLastBackupMessageSeq();
|
150
144
|
console.log('LastBackup messageSeq: ', messageSeq);
|
151
|
-
const total = yield
|
145
|
+
const total = yield getImManager().db.countMessageAfterSeq(messageSeq);
|
152
146
|
console.log('total', total);
|
153
147
|
this.total = total;
|
154
148
|
// 没有需要备份的消息
|
@@ -169,11 +163,10 @@ class MessageBackupUtils extends BaseUtils {
|
|
169
163
|
});
|
170
164
|
return __awaiter(this, void 0, void 0, function* () {
|
171
165
|
_super.cancel.call(this);
|
172
|
-
yield
|
166
|
+
yield cancelBackupMessage(this.batchId);
|
173
167
|
});
|
174
168
|
}
|
175
169
|
}
|
176
|
-
exports.MessageBackupUtils = MessageBackupUtils;
|
177
170
|
class RestoreTaskItem extends TaskItem {
|
178
171
|
constructor(pageNum, pageSize) {
|
179
172
|
super(pageNum, pageSize);
|
@@ -182,8 +175,8 @@ class RestoreTaskItem extends TaskItem {
|
|
182
175
|
}
|
183
176
|
execute(callback) {
|
184
177
|
return __awaiter(this, void 0, void 0, function* () {
|
185
|
-
const { data: { records: [messages] } } = yield
|
186
|
-
const imManager =
|
178
|
+
const { data: { records: [messages] } } = yield queryMyBackMessage({ pageNum: this.pageNum, pageSize: this.pageSize }, { cancelToken: this.cancelToken.token });
|
179
|
+
const imManager = getImManager();
|
187
180
|
yield Promise.all(messages.map(item => {
|
188
181
|
return (() => __awaiter(this, void 0, void 0, function* () {
|
189
182
|
const message = JSON.parse(item);
|
@@ -207,7 +200,7 @@ class RestoreTaskItem extends TaskItem {
|
|
207
200
|
});
|
208
201
|
}
|
209
202
|
}
|
210
|
-
class MessageRestoreUtils extends BaseUtils {
|
203
|
+
export class MessageRestoreUtils extends BaseUtils {
|
211
204
|
constructor(callback) {
|
212
205
|
super(callback);
|
213
206
|
// 默认每页1个批次的多条数据,按批次处理进度
|
@@ -223,7 +216,7 @@ class MessageRestoreUtils extends BaseUtils {
|
|
223
216
|
start() {
|
224
217
|
return __awaiter(this, void 0, void 0, function* () {
|
225
218
|
this.state = 'running';
|
226
|
-
const { data: { total, } } = yield
|
219
|
+
const { data: { total, } } = yield queryMyBackMessage({ pageNum: 1, pageSize: 1 });
|
227
220
|
console.log('total: ', total);
|
228
221
|
this.total = total;
|
229
222
|
const length = Math.ceil(this.total / this.pageSize);
|
@@ -236,4 +229,3 @@ class MessageRestoreUtils extends BaseUtils {
|
|
236
229
|
});
|
237
230
|
}
|
238
231
|
}
|
239
|
-
exports.MessageRestoreUtils = MessageRestoreUtils;
|
@@ -1,94 +1,68 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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 im_base_1 = require("@smart-link/im-base");
|
30
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
31
|
-
const react_1 = __importStar(require("react"));
|
32
|
-
const react_native_1 = require("react-native");
|
33
|
-
const FontAwesome5_1 = __importDefault(require("react-native-vector-icons/FontAwesome5"));
|
34
|
-
const useImSelector_1 = require("../../hooks/useImSelector");
|
35
|
-
const useTranslation_1 = __importDefault(require("../../hooks/useTranslation"));
|
36
|
-
const init_1 = require("../../init");
|
37
|
-
const MessageBar_1 = __importDefault(require("./components/messageBar/MessageBar"));
|
38
|
-
const MessageItem_1 = __importDefault(require("./components/MessageItem"));
|
39
|
-
const MessageOption_1 = __importDefault(require("./components/MessageOption"));
|
40
|
-
const VideoPlayer_1 = __importDefault(require("../../components/VideoPlayer"));
|
41
|
-
const MessageItemQuote_1 = __importDefault(require("../../pages/message/components/MessageItemQuote"));
|
42
|
-
const MessagePictureAlbum_1 = __importDefault(require("./components/MessagePictureAlbum"));
|
43
|
-
const MultipleBar_1 = __importDefault(require("./components/MultipleBar"));
|
44
|
-
const ChatBg_1 = __importDefault(require("./components/ChatBg"));
|
45
|
-
const ahooks_1 = require("ahooks");
|
46
|
-
const MessageItemTips_1 = __importDefault(require("./components/MessageItemTips"));
|
1
|
+
import { ConversationType, MessageActions, MessagePanelActions, PayloadType, TipsType, showTimeLine, } from '@smart-link/im-base';
|
2
|
+
import { dp, HeaderBackButton, Input, NavigationPage } from '@smart-link/rn-ui';
|
3
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
4
|
+
import { View, Text, FlatList, TouchableOpacity, Keyboard, InteractionManager, StyleSheet, ActivityIndicator, TouchableWithoutFeedback } from 'react-native';
|
5
|
+
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
6
|
+
import { useAuth, useConversation, useMessage } from '../../hooks/useImSelector';
|
7
|
+
import useTranslation from '../../hooks/useTranslation';
|
8
|
+
import { getImManager } from '../../init';
|
9
|
+
import MessageBar from './components/messageBar/MessageBar';
|
10
|
+
import MessageItem from './components/MessageItem';
|
11
|
+
import MessageOption from './components/MessageOption';
|
12
|
+
import MessageItemQuote from './components/MessageItemQuote';
|
13
|
+
import MessagePictureAlbum from './components/MessagePictureAlbum';
|
14
|
+
import MultipleBar from './components/MultipleBar';
|
15
|
+
import ChatBg from './components/ChatBg';
|
16
|
+
import { useMemoizedFn } from "ahooks";
|
17
|
+
import MessageItemTips from './components/MessageItemTips';
|
18
|
+
import FastImage from "react-native-fast-image";
|
19
|
+
import { noMessageImg } from "../../default-assets";
|
47
20
|
const MessageList = ({ navigation }) => {
|
48
|
-
const { t } = (
|
49
|
-
const messageListRef =
|
50
|
-
const { currentConversation } =
|
51
|
-
const { messages, rangeList, quote, tips, isMultiple, multipleSelect, isSearch } =
|
52
|
-
const { user } =
|
53
|
-
const bar =
|
54
|
-
const [showAlbum, setShowAlbum] =
|
55
|
-
const [targetMessageSeq, setTargetMessageSeq] =
|
56
|
-
const [selectMessage, setSelectMessage] =
|
57
|
-
const [nativeEvent, setNativeEvent] =
|
58
|
-
const [loading, setLoading] =
|
59
|
-
const
|
60
|
-
(0
|
21
|
+
const { t } = useTranslation();
|
22
|
+
const messageListRef = useRef(null);
|
23
|
+
const { currentConversation } = useConversation();
|
24
|
+
const { messages, rangeList, quote, tips, isMultiple, multipleSelect, isSearch } = useMessage();
|
25
|
+
const { user } = useAuth();
|
26
|
+
const bar = useRef(null);
|
27
|
+
const [showAlbum, setShowAlbum] = useState(false);
|
28
|
+
const [targetMessageSeq, setTargetMessageSeq] = useState('');
|
29
|
+
const [selectMessage, setSelectMessage] = useState();
|
30
|
+
const [nativeEvent, setNativeEvent] = useState();
|
31
|
+
const [loading, setLoading] = useState(false);
|
32
|
+
const itemLayout = useRef({});
|
33
|
+
const isB2C = (currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) === ConversationType.B2C;
|
34
|
+
useEffect(() => {
|
61
35
|
console.log('[进入会话]: ', currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.name);
|
62
36
|
if (currentConversation) {
|
63
37
|
navigation.setOptions({
|
64
38
|
headerLeft: isMultiple
|
65
|
-
? () => (<
|
66
|
-
|
39
|
+
? () => (<TouchableOpacity onPress={() => {
|
40
|
+
getImManager().store.dispatch(MessagePanelActions.cancelMultipleSelect());
|
67
41
|
}}>
|
68
|
-
<
|
69
|
-
</
|
70
|
-
:
|
71
|
-
headerTitle: ({ tintColor }) => (<
|
72
|
-
<
|
73
|
-
</
|
74
|
-
headerRight: ({ tintColor }) => (<
|
42
|
+
<Text style={{ color: '#fff' }}>{t('cancel')}</Text>
|
43
|
+
</TouchableOpacity>)
|
44
|
+
: HeaderBackButton,
|
45
|
+
headerTitle: ({ tintColor }) => (<View style={{ width: dp(220) }}>
|
46
|
+
<Text numberOfLines={1} style={{ color: tintColor, fontSize: dp(18), textAlign: 'center' }}>{currentConversation.name}</Text>
|
47
|
+
</View>),
|
48
|
+
headerRight: ({ tintColor }) => (<TouchableOpacity onPress={() => {
|
75
49
|
navigation.navigate('ConversationSetting');
|
76
|
-
}} style={{ width:
|
77
|
-
<
|
78
|
-
</
|
50
|
+
}} style={{ width: dp(40), justifyContent: 'center', alignItems: 'center' }}>
|
51
|
+
<FontAwesome5 name="ellipsis-h" color={tintColor} size={dp(18)}/>
|
52
|
+
</TouchableOpacity>),
|
79
53
|
});
|
80
54
|
}
|
81
55
|
let remover = navigation.addListener('beforeRemove', e => {
|
82
|
-
const imManager =
|
56
|
+
const imManager = getImManager();
|
83
57
|
if (isMultiple) {
|
84
58
|
e.preventDefault();
|
85
|
-
imManager.store.dispatch(
|
59
|
+
imManager.store.dispatch(MessagePanelActions.cancelMultipleSelect());
|
86
60
|
}
|
87
61
|
else {
|
88
|
-
|
89
|
-
|
90
|
-
react_native_1.InteractionManager.runAfterInteractions(() => {
|
62
|
+
InteractionManager.runAfterInteractions(() => {
|
63
|
+
imManager.store.dispatch(MessagePanelActions.saveDraftText(imManager));
|
91
64
|
imManager.leaveConversation();
|
65
|
+
imManager.store.dispatch(MessageActions.resetState());
|
92
66
|
});
|
93
67
|
}
|
94
68
|
});
|
@@ -96,97 +70,130 @@ const MessageList = ({ navigation }) => {
|
|
96
70
|
remover();
|
97
71
|
};
|
98
72
|
}, [isMultiple, navigation, currentConversation]);
|
99
|
-
|
100
|
-
|
101
|
-
|
73
|
+
useEffect(() => {
|
74
|
+
getImManager().setFlatListRef(messageListRef);
|
75
|
+
getImManager().setInputRef(bar);
|
102
76
|
}, []);
|
103
|
-
|
77
|
+
useEffect(() => {
|
104
78
|
var _a;
|
105
79
|
if (isSearch) {
|
106
80
|
(_a = messageListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToOffset({ animated: false, offset: 0 });
|
107
|
-
|
81
|
+
getImManager().store.dispatch(MessageActions.setIsSearch(false));
|
108
82
|
}
|
109
83
|
}, [isSearch]);
|
110
|
-
const onLongPressPopover =
|
84
|
+
const onLongPressPopover = useCallback((message, nativeEvent) => {
|
111
85
|
setNativeEvent(nativeEvent);
|
112
86
|
setSelectMessage(message);
|
113
87
|
}, []);
|
114
|
-
const onLayoutItem =
|
88
|
+
const onLayoutItem = useMemoizedFn((message, e) => {
|
89
|
+
itemLayout.current[message.messageSeq] = e.nativeEvent.layout.height;
|
115
90
|
if (rangeList.length > 0 && message.messageSeq === (tips === null || tips === void 0 ? void 0 : tips.messageSeq)) {
|
116
|
-
const imManager =
|
117
|
-
imManager.store.dispatch(
|
91
|
+
const imManager = getImManager();
|
92
|
+
imManager.store.dispatch(MessagePanelActions.onRangeLayout(imManager));
|
118
93
|
}
|
119
94
|
});
|
120
|
-
const
|
121
|
-
|
95
|
+
const onLoadBefore = useMemoizedFn(() => {
|
96
|
+
getImManager()
|
97
|
+
.loadBeforeMessages(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.id, { limit: 15 })
|
98
|
+
.then(() => {
|
99
|
+
console.log('loaded');
|
100
|
+
});
|
101
|
+
});
|
102
|
+
const onLoadAfter = useMemoizedFn(() => {
|
103
|
+
getImManager()
|
104
|
+
.loadAfterMessages(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.id, { limit: 15 })
|
105
|
+
.then(() => {
|
106
|
+
console.log('loaded');
|
107
|
+
});
|
108
|
+
});
|
109
|
+
const renderItem = useMemoizedFn(({ item, index }) => {
|
110
|
+
return (<MessageItem message={item} conversation={currentConversation} mine={item.messageFrom === user.userId} showTimeLine={showTimeLine(item, index, messages)} isMultiple={isMultiple} multipleSelect={multipleSelect} onLongPressPopover={onLongPressPopover} onPressPopover={onPressPopover} onLayoutItem={onLayoutItem}/>);
|
111
|
+
});
|
112
|
+
const onTouchStart = useCallback(() => {
|
113
|
+
var _a;
|
114
|
+
(_a = bar.current) === null || _a === void 0 ? void 0 : _a.reset();
|
115
|
+
}, []);
|
116
|
+
const onPressPopover = useCallback((message, nativeEvent) => {
|
117
|
+
if (message.payloadType === PayloadType.PICTURE) {
|
122
118
|
setNativeEvent(nativeEvent);
|
123
119
|
setShowAlbum(true);
|
124
120
|
setTargetMessageSeq(message.messageSeq);
|
125
121
|
}
|
126
122
|
}, []);
|
127
123
|
const onKeyboardAt = () => {
|
128
|
-
if ((currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) ===
|
129
|
-
|
124
|
+
if ((currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) === ConversationType.C2G) {
|
125
|
+
Keyboard.dismiss();
|
130
126
|
navigation.navigate('ChooseMember', { atOther: true });
|
131
127
|
}
|
132
128
|
};
|
133
|
-
return (<
|
134
|
-
{(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) ===
|
135
|
-
<
|
136
|
-
</
|
137
|
-
|
129
|
+
return (<NavigationPage noPadding>
|
130
|
+
{(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) === ConversationType.B2C && (<View style={{ padding: dp(8), backgroundColor: '#f5f5f5', elevation: 1 }}>
|
131
|
+
<Input shape="normal" placeholder={t('search')} wrapStyle={{ height: dp(40) }}/>
|
132
|
+
</View>)}
|
133
|
+
|
134
|
+
{messages.length === 0 && (<TouchableWithoutFeedback onPress={onTouchStart} style={{ flex: 1 }}>
|
135
|
+
<View style={styles.empty}>
|
136
|
+
<FastImage source={noMessageImg} style={styles.noMessageImg}/>
|
137
|
+
<Text style={styles.noMessageText}>
|
138
|
+
{t('noChatMessage')}
|
139
|
+
</Text>
|
140
|
+
</View>
|
141
|
+
</TouchableWithoutFeedback>)}
|
142
|
+
|
143
|
+
{messages.length > 0 && (<ChatBg fileId={currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.imageBackground}>
|
138
144
|
<>
|
139
|
-
<
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
}} refreshing={false} onRefresh={() => {
|
153
|
-
(0, init_1.getImManager)()
|
154
|
-
.loadAfterMessages(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.id, { limit: 15 })
|
155
|
-
.then(() => {
|
156
|
-
console.log('loaded last');
|
157
|
-
});
|
158
|
-
}} onTouchStart={() => {
|
159
|
-
var _a;
|
160
|
-
(_a = bar.current) === null || _a === void 0 ? void 0 : _a.reset();
|
161
|
-
}} onLayout={() => {
|
162
|
-
}}/>
|
163
|
-
{quote && (<MessageItemQuote_1.default {...quote} onDeleteQuote={() => {
|
164
|
-
(0, init_1.getImManager)().store.dispatch(im_base_1.MessageActions.setQuote(null));
|
165
|
-
}}/>)}
|
145
|
+
<FlatList ref={messageListRef} inverted contentContainerStyle={{
|
146
|
+
paddingVertical: dp(20),
|
147
|
+
justifyContent: 'flex-end',
|
148
|
+
flexGrow: 1,
|
149
|
+
overflow: 'scroll',
|
150
|
+
}} numColumns={1} onEndReachedThreshold={0.1} keyboardShouldPersistTaps={'handled'} keyExtractor={item => item.messageSeq} renderItem={renderItem} data={messages} onEndReached={onLoadBefore} refreshing={false}
|
151
|
+
// 在头部增加数据时,保持滚动位置,0.72 以上可以使用
|
152
|
+
maintainVisibleContentPosition={{
|
153
|
+
minIndexForVisible: 0,
|
154
|
+
}} onRefresh={onLoadAfter} onTouchStart={onTouchStart}/>
|
155
|
+
{quote && (<MessageItemQuote {...quote} onDeleteQuote={() => {
|
156
|
+
getImManager().store.dispatch(MessageActions.setQuote(null));
|
157
|
+
}}/>)}
|
166
158
|
</>
|
167
|
-
</
|
159
|
+
</ChatBg>)}
|
168
160
|
|
169
|
-
{!isB2C && (isMultiple ? <
|
161
|
+
{!isB2C && (isMultiple ? <MultipleBar /> : <MessageBar ref={bar} onKeyboardAt={onKeyboardAt}/>)}
|
170
162
|
|
171
|
-
{tips && tips.type
|
172
|
-
<
|
173
|
-
<MessageOption_1.default visible={Boolean(selectMessage)} nativeEvent={nativeEvent} message={selectMessage} setLoading={(value) => {
|
163
|
+
{tips && tips.type !== TipsType.NONE && (<MessageItemTips {...tips}/>)}
|
164
|
+
<MessageOption visible={Boolean(selectMessage)} nativeEvent={nativeEvent} message={selectMessage} setLoading={(value) => {
|
174
165
|
setLoading(value);
|
175
166
|
}} onClose={() => {
|
176
167
|
setNativeEvent(undefined);
|
177
168
|
setSelectMessage(undefined);
|
178
169
|
}}/>
|
179
170
|
|
180
|
-
<
|
171
|
+
<MessagePictureAlbum visible={showAlbum} messages={messages} messageSeq={targetMessageSeq} onClose={() => {
|
181
172
|
setShowAlbum(false);
|
182
173
|
}}/>
|
183
174
|
|
184
|
-
{loading && (<
|
185
|
-
<
|
186
|
-
</
|
187
|
-
</
|
175
|
+
{loading && (<View style={styles.loadingContainer}>
|
176
|
+
<ActivityIndicator size="large" color="#FFFFFF"/>
|
177
|
+
</View>)}
|
178
|
+
</NavigationPage>);
|
188
179
|
};
|
189
|
-
const styles =
|
190
|
-
loadingContainer: Object.assign(Object.assign({},
|
180
|
+
const styles = StyleSheet.create({
|
181
|
+
loadingContainer: Object.assign(Object.assign({}, StyleSheet.absoluteFillObject), { backgroundColor: 'rgba(0, 0, 0, 0.5)', justifyContent: 'center', alignItems: 'center', zIndex: 9999 }),
|
182
|
+
empty: {
|
183
|
+
flex: 1,
|
184
|
+
justifyContent: 'center',
|
185
|
+
alignItems: 'center',
|
186
|
+
},
|
187
|
+
noMessageImg: {
|
188
|
+
alignSelf: 'center',
|
189
|
+
width: dp(152),
|
190
|
+
height: dp(122)
|
191
|
+
},
|
192
|
+
noMessageText: {
|
193
|
+
alignSelf: 'center',
|
194
|
+
fontSize: dp(14),
|
195
|
+
lineHeight: dp(16),
|
196
|
+
color: "#999999"
|
197
|
+
},
|
191
198
|
});
|
192
|
-
|
199
|
+
export default MessageList;
|
@@ -1,52 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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 ChatAvatar_1 = __importDefault(require("../../components/ChatAvatar/ChatAvatar"));
|
30
|
-
const FormatTimeText_1 = __importDefault(require("../../components/FormatTimeText"));
|
31
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
32
|
-
const react_1 = __importStar(require("react"));
|
33
|
-
const react_native_1 = require("react-native");
|
34
|
-
const MessagePayload_1 = __importDefault(require("./components/MessagePayload"));
|
35
|
-
const MessagePictureAlbum_1 = __importDefault(require("./components/MessagePictureAlbum"));
|
36
|
-
const lodash_es_1 = require("lodash-es");
|
1
|
+
import ChatAvatar from '../../components/ChatAvatar/ChatAvatar';
|
2
|
+
import FormatTimeText from '../../components/FormatTimeText';
|
3
|
+
import { dp, NavigationPage } from '@smart-link/rn-ui';
|
4
|
+
import React, { useEffect } from 'react';
|
5
|
+
import { View, StyleSheet, FlatList, Text } from 'react-native';
|
6
|
+
import MessagePayload from './components/MessagePayload';
|
7
|
+
import MessagePictureAlbum from "./components/MessagePictureAlbum";
|
8
|
+
import { cloneDeep } from "lodash-es";
|
37
9
|
const MessageRecord = ({ navigation, route: { params } }) => {
|
38
|
-
const { messages,
|
39
|
-
|
10
|
+
const { messages, title } = params;
|
11
|
+
useEffect(() => {
|
40
12
|
navigation.setOptions({
|
41
13
|
title,
|
42
14
|
});
|
43
15
|
}, [navigation, title]);
|
44
|
-
const
|
45
|
-
const [
|
46
|
-
const [
|
47
|
-
const [
|
48
|
-
|
49
|
-
|
16
|
+
const listRef = React.useRef(null);
|
17
|
+
const [updateMessages, setUpdateMessages] = React.useState([]);
|
18
|
+
const [previewMessages, setPreviewMessages] = React.useState([]);
|
19
|
+
const [showAlbum, setShowAlbum] = React.useState(false);
|
20
|
+
const [targetMessageSeq, setTargetMessageSeq] = React.useState('');
|
21
|
+
useEffect(() => {
|
22
|
+
var _a;
|
23
|
+
setUpdateMessages(cloneDeep(messages));
|
24
|
+
(_a = listRef.current) === null || _a === void 0 ? void 0 : _a.scrollToOffset({ animated: false, offset: 0 });
|
50
25
|
}, [messages]);
|
51
26
|
const onPress = (item) => {
|
52
27
|
var _a;
|
@@ -63,19 +38,20 @@ const MessageRecord = ({ navigation, route: { params } }) => {
|
|
63
38
|
setPreviewMessages(updateMessages);
|
64
39
|
}
|
65
40
|
};
|
66
|
-
return (<
|
67
|
-
<
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
<
|
77
|
-
|
78
|
-
|
41
|
+
return (<NavigationPage noPadding>
|
42
|
+
<FlatList ref={listRef} contentContainerStyle={styles.list} data={updateMessages} renderItem={({ item, index }) => {
|
43
|
+
console.log('index: ', index);
|
44
|
+
const isSamePerson = index > 0 && updateMessages.length > 1 && updateMessages[index - 1].messageFrom === item.messageFrom;
|
45
|
+
return (<View style={styles.messageItem}>
|
46
|
+
<View style={styles.avatar}>
|
47
|
+
{!isSamePerson && (<ChatAvatar id={item.messageFrom} url={item.payload.avatars} size={dp(40)} name={item.messageFromName}/>)}
|
48
|
+
</View>
|
49
|
+
<View style={styles.content}>
|
50
|
+
<View style={styles.info}>
|
51
|
+
<Text style={styles.usernameText}>{item.messageFromName}</Text>
|
52
|
+
<FormatTimeText style={styles.timeText} time={item.messageTime}></FormatTimeText>
|
53
|
+
</View>
|
54
|
+
<MessagePayload {...item} isRecord direction="left" showArrow={false} onPress={() => {
|
79
55
|
onPress(item);
|
80
56
|
}} onLoad={(localPath) => {
|
81
57
|
console.log('localPath: ', localPath);
|
@@ -83,49 +59,49 @@ const MessageRecord = ({ navigation, route: { params } }) => {
|
|
83
59
|
item.payload.localPath = localPath;
|
84
60
|
}
|
85
61
|
}}/>
|
86
|
-
</
|
87
|
-
</
|
62
|
+
</View>
|
63
|
+
</View>);
|
88
64
|
}}/>
|
89
|
-
<
|
65
|
+
<MessagePictureAlbum visible={showAlbum} messages={previewMessages} messageSeq={targetMessageSeq} onClose={() => {
|
90
66
|
setShowAlbum(false);
|
91
67
|
}}/>
|
92
|
-
</
|
68
|
+
</NavigationPage>);
|
93
69
|
};
|
94
|
-
const styles =
|
70
|
+
const styles = StyleSheet.create({
|
95
71
|
list: {
|
96
|
-
padding:
|
72
|
+
padding: dp(12),
|
97
73
|
},
|
98
74
|
titleText: {
|
99
|
-
fontSize:
|
75
|
+
fontSize: dp(16),
|
100
76
|
color: '#fff',
|
101
77
|
},
|
102
78
|
messageItem: {
|
103
79
|
flexDirection: 'row',
|
104
|
-
marginBottom:
|
80
|
+
marginBottom: dp(10),
|
105
81
|
},
|
106
82
|
avatar: {
|
107
|
-
width:
|
83
|
+
width: dp(40),
|
108
84
|
},
|
109
85
|
content: {
|
110
86
|
flex: 1,
|
111
|
-
marginHorizontal:
|
112
|
-
paddingVertical:
|
113
|
-
borderBottomWidth:
|
87
|
+
marginHorizontal: dp(6),
|
88
|
+
paddingVertical: dp(4),
|
89
|
+
borderBottomWidth: dp(1),
|
114
90
|
borderStyle: 'solid',
|
115
91
|
borderColor: '#eee',
|
116
92
|
},
|
117
93
|
info: {
|
118
94
|
flexDirection: 'row',
|
119
95
|
justifyContent: 'space-between',
|
120
|
-
marginBottom:
|
96
|
+
marginBottom: dp(5),
|
121
97
|
},
|
122
98
|
usernameText: {
|
123
99
|
color: '#999',
|
124
|
-
fontSize:
|
100
|
+
fontSize: dp(12),
|
125
101
|
},
|
126
102
|
timeText: {
|
127
103
|
color: '#999',
|
128
|
-
fontSize:
|
104
|
+
fontSize: dp(12),
|
129
105
|
},
|
130
106
|
});
|
131
|
-
|
107
|
+
export default MessageRecord;
|