@smart-link/rn-im 1.0.23 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/file-dir.jpg +0 -0
- 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 +22 -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 +2 -0
- package/dist/default-assets.js +9 -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.d.ts +9 -0
- 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.d.ts +1 -1
- 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.d.ts +1 -1
- 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 +50 -56
- 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/FileSelector.d.ts +6 -0
- package/dist/pages/message/FileSelector.js +235 -0
- 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 +151 -141
- package/dist/pages/message/MessageRecord.js +74 -87
- package/dist/pages/message/components/BusiNotifyCard.js +60 -85
- package/dist/pages/message/components/ChatBg.js +11 -36
- package/dist/pages/message/components/MessageItem.d.ts +2 -1
- package/dist/pages/message/components/MessageItem.js +85 -112
- package/dist/pages/message/components/MessageItemQuote.js +30 -58
- package/dist/pages/message/components/MessageItemTips.js +27 -55
- package/dist/pages/message/components/MessageOption.d.ts +7 -3
- package/dist/pages/message/components/MessageOption.js +107 -134
- package/dist/pages/message/components/MessagePayload.d.ts +2 -1
- 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.d.ts +1 -1
- package/dist/pages/message/components/Payload/PayloadFile.js +44 -68
- package/dist/pages/message/components/Payload/PayloadMultiple.js +46 -70
- package/dist/pages/message/components/Payload/PayloadNotify.js +28 -56
- package/dist/pages/message/components/Payload/PayloadPicture.d.ts +1 -1
- package/dist/pages/message/components/Payload/PayloadPicture.js +21 -50
- 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 +30 -57
- package/dist/pages/message/components/Payload/PayloadVoice.js +80 -93
- package/dist/pages/message/components/Payload/PayloadWrapper.d.ts +2 -1
- package/dist/pages/message/components/Payload/PayloadWrapper.js +24 -44
- package/dist/pages/message/components/Payload/type.d.ts +2 -1
- package/dist/pages/message/components/Payload/type.js +1 -2
- package/dist/pages/message/components/ReceiptBack.js +30 -60
- package/dist/pages/message/components/TextMixMessage.js +13 -38
- package/dist/pages/message/components/TextMixQuote.js +128 -162
- package/dist/pages/message/components/TextMixQuoteMessage.js +19 -47
- 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 -107
- 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 +21 -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.d.ts +4 -2
- package/dist/pages/types.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 +64 -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 +10 -2
- package/dist/utils/file.js +188 -88
- 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
- package/dist/slice/contact/contact.action.d.ts +0 -1
- package/dist/slice/contact/contact.action.js +0 -2
@@ -1,95 +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 [
|
58
|
-
const [
|
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 [loading, setLoading] = useState(false);
|
31
|
+
const [touchPoint, setTouchPoint] = useState();
|
32
|
+
const [targetLayout, setTargetLayout] = useState();
|
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
|
-
imManager.store.dispatch(im_base_1.MessagePanelActions.saveDraftText(imManager));
|
62
|
+
InteractionManager.runAfterInteractions(() => {
|
63
|
+
imManager.store.dispatch(MessagePanelActions.saveDraftText(imManager));
|
91
64
|
imManager.leaveConversation();
|
92
|
-
imManager.store.dispatch(
|
65
|
+
imManager.store.dispatch(MessageActions.resetState({}));
|
93
66
|
});
|
94
67
|
}
|
95
68
|
});
|
@@ -97,97 +70,134 @@ const MessageList = ({ navigation }) => {
|
|
97
70
|
remover();
|
98
71
|
};
|
99
72
|
}, [isMultiple, navigation, currentConversation]);
|
100
|
-
|
101
|
-
|
102
|
-
|
73
|
+
useEffect(() => {
|
74
|
+
getImManager().setFlatListRef(messageListRef);
|
75
|
+
getImManager().setInputRef(bar);
|
103
76
|
}, []);
|
104
|
-
|
77
|
+
useEffect(() => {
|
105
78
|
var _a;
|
106
79
|
if (isSearch) {
|
107
80
|
(_a = messageListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToOffset({ animated: false, offset: 0 });
|
108
|
-
|
81
|
+
getImManager().store.dispatch(MessageActions.setIsSearch(false));
|
109
82
|
}
|
110
83
|
}, [isSearch]);
|
111
|
-
const
|
112
|
-
|
84
|
+
const onPressPopover = useCallback((message, nativeEvent) => {
|
85
|
+
if (message.payloadType === PayloadType.PICTURE) {
|
86
|
+
setShowAlbum(true);
|
87
|
+
setSelectMessage(undefined);
|
88
|
+
setTargetMessageSeq(message.messageSeq);
|
89
|
+
}
|
90
|
+
}, []);
|
91
|
+
const onLongPressPopover = useCallback((message, nativeEvent, layout) => {
|
113
92
|
setSelectMessage(message);
|
93
|
+
setTouchPoint({
|
94
|
+
x: nativeEvent.pageX - nativeEvent.locationX,
|
95
|
+
y: nativeEvent.pageY - nativeEvent.locationY
|
96
|
+
});
|
97
|
+
setTargetLayout(layout);
|
114
98
|
}, []);
|
115
|
-
const onLayoutItem =
|
99
|
+
const onLayoutItem = useMemoizedFn((message, e) => {
|
116
100
|
if (rangeList.length > 0 && message.messageSeq === (tips === null || tips === void 0 ? void 0 : tips.messageSeq)) {
|
117
|
-
const imManager =
|
118
|
-
imManager.store.dispatch(
|
101
|
+
const imManager = getImManager();
|
102
|
+
imManager.store.dispatch(MessagePanelActions.onRangeLayout(imManager));
|
119
103
|
}
|
120
104
|
});
|
121
|
-
const
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
}
|
105
|
+
const onLoadBefore = useMemoizedFn(() => {
|
106
|
+
getImManager()
|
107
|
+
.loadBeforeMessages(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.id, { limit: 15 })
|
108
|
+
.then(() => {
|
109
|
+
console.log('loaded');
|
110
|
+
});
|
111
|
+
});
|
112
|
+
const onLoadAfter = useMemoizedFn(() => {
|
113
|
+
getImManager()
|
114
|
+
.loadAfterMessages(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.id, { limit: 15 })
|
115
|
+
.then(() => {
|
116
|
+
console.log('loaded');
|
117
|
+
});
|
118
|
+
});
|
119
|
+
const renderItem = useMemoizedFn(({ item, index }) => {
|
120
|
+
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}/>);
|
121
|
+
});
|
122
|
+
const onTouchStart = useCallback(() => {
|
123
|
+
var _a;
|
124
|
+
(_a = bar.current) === null || _a === void 0 ? void 0 : _a.reset();
|
127
125
|
}, []);
|
128
126
|
const onKeyboardAt = () => {
|
129
|
-
if ((currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) ===
|
130
|
-
|
127
|
+
if ((currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) === ConversationType.C2G) {
|
128
|
+
Keyboard.dismiss();
|
131
129
|
navigation.navigate('ChooseMember', { atOther: true });
|
132
130
|
}
|
133
131
|
};
|
134
|
-
return (<
|
135
|
-
{(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) ===
|
136
|
-
<
|
137
|
-
</
|
138
|
-
|
132
|
+
return (<NavigationPage noPadding>
|
133
|
+
{(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) === ConversationType.B2C && (<View style={{ padding: dp(8), backgroundColor: '#f5f5f5', elevation: 1 }}>
|
134
|
+
<Input shape="normal" placeholder={t('search')} wrapStyle={{ height: dp(40) }}/>
|
135
|
+
</View>)}
|
136
|
+
|
137
|
+
{messages.length === 0 && (<TouchableWithoutFeedback onPress={onTouchStart} style={{ flex: 1 }}>
|
138
|
+
<View style={styles.empty}>
|
139
|
+
<FastImage source={noMessageImg} style={styles.noMessageImg}/>
|
140
|
+
<Text style={styles.noMessageText}>
|
141
|
+
{t('noChatMessage')}
|
142
|
+
</Text>
|
143
|
+
</View>
|
144
|
+
</TouchableWithoutFeedback>)}
|
145
|
+
|
146
|
+
{messages.length > 0 && (<ChatBg fileId={currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.imageBackground}>
|
139
147
|
<>
|
140
|
-
<
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}} refreshing={false} onRefresh={() => {
|
154
|
-
(0, init_1.getImManager)()
|
155
|
-
.loadAfterMessages(currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.id, { limit: 15 })
|
156
|
-
.then(() => {
|
157
|
-
console.log('loaded last');
|
158
|
-
});
|
159
|
-
}} onTouchStart={() => {
|
160
|
-
var _a;
|
161
|
-
(_a = bar.current) === null || _a === void 0 ? void 0 : _a.reset();
|
162
|
-
}} onLayout={() => {
|
163
|
-
}}/>
|
164
|
-
{quote && (<MessageItemQuote_1.default {...quote} onDeleteQuote={() => {
|
165
|
-
(0, init_1.getImManager)().store.dispatch(im_base_1.MessageActions.setQuote(null));
|
166
|
-
}}/>)}
|
148
|
+
<FlatList ref={messageListRef} inverted contentContainerStyle={{
|
149
|
+
paddingVertical: dp(20),
|
150
|
+
justifyContent: 'flex-end',
|
151
|
+
flexGrow: 1,
|
152
|
+
overflow: 'scroll',
|
153
|
+
}} numColumns={1} onEndReachedThreshold={0.1} keyboardShouldPersistTaps={'handled'} keyExtractor={item => item.messageSeq} renderItem={renderItem} data={messages} onEndReached={onLoadBefore} refreshing={false}
|
154
|
+
// 在头部增加数据时,保持滚动位置,0.72 以上可以使用
|
155
|
+
maintainVisibleContentPosition={{
|
156
|
+
minIndexForVisible: 0,
|
157
|
+
}} onRefresh={onLoadAfter} onTouchStart={onTouchStart}/>
|
158
|
+
{quote && (<MessageItemQuote {...quote} onDeleteQuote={() => {
|
159
|
+
getImManager().store.dispatch(MessageActions.setQuote(null));
|
160
|
+
}}/>)}
|
167
161
|
</>
|
168
|
-
</
|
162
|
+
</ChatBg>)}
|
169
163
|
|
170
|
-
{!isB2C && (isMultiple ? <
|
164
|
+
{!isB2C && (isMultiple ? <MultipleBar /> : <MessageBar ref={bar} onKeyboardAt={onKeyboardAt}/>)}
|
171
165
|
|
172
|
-
{tips && tips.type
|
173
|
-
<
|
174
|
-
<MessageOption_1.default visible={Boolean(selectMessage)} nativeEvent={nativeEvent} message={selectMessage} setLoading={(value) => {
|
166
|
+
{tips && tips.type !== TipsType.NONE && (<MessageItemTips {...tips}/>)}
|
167
|
+
<MessageOption visible={Boolean(selectMessage)} touchPoint={touchPoint} nativeEventLayout={targetLayout} message={selectMessage} setLoading={(value) => {
|
175
168
|
setLoading(value);
|
176
169
|
}} onClose={() => {
|
177
|
-
setNativeEvent(undefined);
|
178
170
|
setSelectMessage(undefined);
|
171
|
+
setTargetLayout(undefined);
|
172
|
+
setTouchPoint(undefined);
|
179
173
|
}}/>
|
180
174
|
|
181
|
-
<
|
175
|
+
<MessagePictureAlbum visible={showAlbum} messages={messages} messageSeq={targetMessageSeq} onClose={() => {
|
182
176
|
setShowAlbum(false);
|
183
177
|
}}/>
|
184
178
|
|
185
|
-
{loading && (<
|
186
|
-
<
|
187
|
-
</
|
188
|
-
</
|
179
|
+
{loading && (<View style={styles.loadingContainer}>
|
180
|
+
<ActivityIndicator size="large" color="#FFFFFF"/>
|
181
|
+
</View>)}
|
182
|
+
</NavigationPage>);
|
189
183
|
};
|
190
|
-
const styles =
|
191
|
-
loadingContainer: Object.assign(Object.assign({},
|
184
|
+
const styles = StyleSheet.create({
|
185
|
+
loadingContainer: Object.assign(Object.assign({}, StyleSheet.absoluteFillObject), { backgroundColor: 'rgba(0, 0, 0, 0.5)', justifyContent: 'center', alignItems: 'center', zIndex: 9999 }),
|
186
|
+
empty: {
|
187
|
+
flex: 1,
|
188
|
+
justifyContent: 'center',
|
189
|
+
alignItems: 'center',
|
190
|
+
},
|
191
|
+
noMessageImg: {
|
192
|
+
alignSelf: 'center',
|
193
|
+
width: dp(152),
|
194
|
+
height: dp(122)
|
195
|
+
},
|
196
|
+
noMessageText: {
|
197
|
+
alignSelf: 'center',
|
198
|
+
fontSize: dp(14),
|
199
|
+
lineHeight: dp(16),
|
200
|
+
color: "#999999"
|
201
|
+
},
|
192
202
|
});
|
193
|
-
|
203
|
+
export default MessageList;
|
@@ -1,131 +1,118 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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, useMemo } from 'react';
|
5
|
+
import { View, StyleSheet, FlatList, Text } from 'react-native';
|
6
|
+
import MessagePayload from './components/MessagePayload';
|
7
|
+
import { MessageListActions } from '@smart-link/im-base';
|
8
|
+
import MessagePictureAlbum from "./components/MessagePictureAlbum";
|
9
|
+
import { useMessage } from "../../hooks/useImSelector";
|
10
|
+
import { getImManager } from "../../init";
|
11
|
+
import { loadVideoPlayer } from "../../slice/video/video.action";
|
37
12
|
const MessageRecord = ({ navigation, route: { params } }) => {
|
38
|
-
const {
|
39
|
-
|
13
|
+
const { messageSeq, title } = params;
|
14
|
+
const { messageListData } = useMessage();
|
15
|
+
useEffect(() => {
|
40
16
|
navigation.setOptions({
|
41
17
|
title,
|
42
18
|
});
|
19
|
+
return () => {
|
20
|
+
console.log('back');
|
21
|
+
getImManager().store.dispatch(MessageListActions.removeMessageListData());
|
22
|
+
};
|
43
23
|
}, [navigation, title]);
|
44
|
-
const
|
45
|
-
const [previewMessages, setPreviewMessages] =
|
46
|
-
const [showAlbum, setShowAlbum] =
|
47
|
-
const [targetMessageSeq, setTargetMessageSeq] =
|
48
|
-
|
49
|
-
setUpdateMessages((0, lodash_es_1.cloneDeep)(messages));
|
50
|
-
}, [messages]);
|
51
|
-
const onPress = (item) => {
|
24
|
+
const listRef = React.useRef(null);
|
25
|
+
const [previewMessages, setPreviewMessages] = React.useState([]);
|
26
|
+
const [showAlbum, setShowAlbum] = React.useState(false);
|
27
|
+
const [targetMessageSeq, setTargetMessageSeq] = React.useState('');
|
28
|
+
const data = useMemo(() => {
|
52
29
|
var _a;
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
30
|
+
return ((_a = messageListData.find(item => item.messageSeq === messageSeq)) === null || _a === void 0 ? void 0 : _a.childMessages) || [];
|
31
|
+
}, [messageSeq, messageListData]);
|
32
|
+
useEffect(() => {
|
33
|
+
var _a;
|
34
|
+
(_a = listRef.current) === null || _a === void 0 ? void 0 : _a.scrollToOffset({ animated: false, offset: 0 });
|
35
|
+
}, [messageSeq]);
|
36
|
+
const onPress = (item) => {
|
37
|
+
if (item.payload.quote) {
|
38
|
+
if (item.payload.quote.quoteMessage.payloadType === 'picture') {
|
39
|
+
setShowAlbum(true);
|
40
|
+
setTargetMessageSeq(item.payload.quote.quoteMessage.messageSeq);
|
41
|
+
setPreviewMessages([item.payload.quote.quoteMessage]);
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
if (item.payload.quote.quoteMessage.payloadType === 'video') {
|
45
|
+
getImManager().store.dispatch(loadVideoPlayer({
|
46
|
+
messageSeq: item.payload.quote.quoteMessage.messageSeq,
|
47
|
+
payload: item.payload.quote.quoteMessage.payload,
|
48
|
+
isRecord: true
|
49
|
+
}));
|
50
|
+
}
|
59
51
|
}
|
60
52
|
if (item.payloadType === 'picture') {
|
61
53
|
setShowAlbum(true);
|
62
54
|
setTargetMessageSeq(item.messageSeq);
|
63
|
-
setPreviewMessages(
|
55
|
+
setPreviewMessages(data);
|
64
56
|
}
|
65
57
|
};
|
66
|
-
return (<
|
67
|
-
<
|
68
|
-
const isSamePerson = index > 0 &&
|
69
|
-
return (<
|
70
|
-
<
|
71
|
-
{!isSamePerson && (<
|
72
|
-
</
|
73
|
-
<
|
74
|
-
<
|
75
|
-
<
|
76
|
-
<
|
77
|
-
</
|
78
|
-
<
|
58
|
+
return (<NavigationPage noPadding>
|
59
|
+
<FlatList ref={listRef} contentContainerStyle={styles.list} data={data} renderItem={({ item, index }) => {
|
60
|
+
const isSamePerson = index > 0 && data.length > 1 && data[index - 1].messageFrom === item.messageFrom;
|
61
|
+
return (<View style={styles.messageItem}>
|
62
|
+
<View style={styles.avatar}>
|
63
|
+
{!isSamePerson && (<ChatAvatar id={item.messageFrom} url={item.payload.avatars} size={dp(40)} name={item.messageFromName}/>)}
|
64
|
+
</View>
|
65
|
+
<View style={styles.content}>
|
66
|
+
<View style={styles.info}>
|
67
|
+
<Text style={styles.usernameText}>{item.messageFromName}</Text>
|
68
|
+
<FormatTimeText style={styles.timeText} time={item.messageTime}></FormatTimeText>
|
69
|
+
</View>
|
70
|
+
<MessagePayload {...item} isRecord direction="left" showArrow={false} onPress={() => {
|
79
71
|
onPress(item);
|
80
|
-
}} onLoad={(localPath) => {
|
81
|
-
console.log('localPath: ', localPath);
|
82
|
-
if (!item.payload.localPath) {
|
83
|
-
item.payload.localPath = localPath;
|
84
|
-
}
|
85
72
|
}}/>
|
86
|
-
</
|
87
|
-
</
|
73
|
+
</View>
|
74
|
+
</View>);
|
88
75
|
}}/>
|
89
|
-
<
|
76
|
+
<MessagePictureAlbum visible={showAlbum} messages={previewMessages} messageSeq={targetMessageSeq} onClose={() => {
|
90
77
|
setShowAlbum(false);
|
91
78
|
}}/>
|
92
|
-
</
|
79
|
+
</NavigationPage>);
|
93
80
|
};
|
94
|
-
const styles =
|
81
|
+
const styles = StyleSheet.create({
|
95
82
|
list: {
|
96
|
-
padding:
|
83
|
+
padding: dp(12),
|
97
84
|
},
|
98
85
|
titleText: {
|
99
|
-
fontSize:
|
86
|
+
fontSize: dp(16),
|
100
87
|
color: '#fff',
|
101
88
|
},
|
102
89
|
messageItem: {
|
103
90
|
flexDirection: 'row',
|
104
|
-
marginBottom:
|
91
|
+
marginBottom: dp(10),
|
105
92
|
},
|
106
93
|
avatar: {
|
107
|
-
width:
|
94
|
+
width: dp(40),
|
108
95
|
},
|
109
96
|
content: {
|
110
97
|
flex: 1,
|
111
|
-
marginHorizontal:
|
112
|
-
paddingVertical:
|
113
|
-
borderBottomWidth:
|
98
|
+
marginHorizontal: dp(6),
|
99
|
+
paddingVertical: dp(4),
|
100
|
+
borderBottomWidth: dp(1),
|
114
101
|
borderStyle: 'solid',
|
115
102
|
borderColor: '#eee',
|
116
103
|
},
|
117
104
|
info: {
|
118
105
|
flexDirection: 'row',
|
119
106
|
justifyContent: 'space-between',
|
120
|
-
marginBottom:
|
107
|
+
marginBottom: dp(5),
|
121
108
|
},
|
122
109
|
usernameText: {
|
123
110
|
color: '#999',
|
124
|
-
fontSize:
|
111
|
+
fontSize: dp(12),
|
125
112
|
},
|
126
113
|
timeText: {
|
127
114
|
color: '#999',
|
128
|
-
fontSize:
|
115
|
+
fontSize: dp(12),
|
129
116
|
},
|
130
117
|
});
|
131
|
-
|
118
|
+
export default MessageRecord;
|