@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,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,38 +7,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
8
|
});
|
33
9
|
};
|
34
|
-
|
35
|
-
|
36
|
-
};
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
const
|
48
|
-
const
|
49
|
-
const
|
50
|
-
const
|
51
|
-
const ChatAvatar = ({ id, name, url: fileId, size = (0, rn_ui_1.dp)(40), disabled, type = im_base_1.ConversationType.C2C, editable, onUpdate, priority = 'cache' }) => {
|
52
|
-
const { user } = (0, useImSelector_1.useAuth)();
|
53
|
-
const navigation = (0, rn_ui_1.useNavigation)();
|
54
|
-
const ready = (0, useImReady_1.default)();
|
10
|
+
import { Avatar, dp, useNavigation } from '@smart-link/rn-ui';
|
11
|
+
import React, { memo } from 'react';
|
12
|
+
import { Image, TouchableOpacity } from 'react-native';
|
13
|
+
import ImagePicker from 'react-native-image-crop-picker';
|
14
|
+
import { getImManager } from '../../init';
|
15
|
+
import { ConversationActions, ConversationType, updateGroupInfo } from '@smart-link/im-base';
|
16
|
+
import { defaultAvatars } from '../../default-assets';
|
17
|
+
import uploadFile from '../../utils/upload';
|
18
|
+
import { updateUserInfo } from '../../api/user';
|
19
|
+
import { useAuth } from '../../hooks/useImSelector';
|
20
|
+
import { moveFile } from "../../utils/file";
|
21
|
+
import ChatAvatarId from "./ChatAvatarId";
|
22
|
+
import useImReady from "../../hooks/useImReady";
|
23
|
+
const ChatAvatar = ({ id, name, url: fileId, size = dp(40), disabled, type = ConversationType.C2C, editable, onUpdate, priority = 'cache' }) => {
|
24
|
+
const { user } = useAuth();
|
25
|
+
const navigation = useNavigation();
|
26
|
+
const ready = useImReady();
|
55
27
|
const defaultAvatar = {
|
56
|
-
[
|
57
|
-
[
|
58
|
-
[
|
59
|
-
}[type] ||
|
28
|
+
[ConversationType.C2C]: defaultAvatars.EMPTY,
|
29
|
+
[ConversationType.C2G]: defaultAvatars.GROUP,
|
30
|
+
[ConversationType.B2C]: defaultAvatars.BUSI_NOTIFY,
|
31
|
+
}[type] || defaultAvatars.EMPTY;
|
60
32
|
const onLongPress = () => __awaiter(void 0, void 0, void 0, function* () {
|
61
33
|
if (editable) {
|
62
|
-
const imManager =
|
34
|
+
const imManager = getImManager();
|
63
35
|
let image;
|
64
36
|
try {
|
65
|
-
image = yield
|
37
|
+
image = yield ImagePicker.openPicker({
|
66
38
|
cropping: true,
|
67
39
|
width: 300,
|
68
40
|
height: 300,
|
@@ -74,15 +46,15 @@ const ChatAvatar = ({ id, name, url: fileId, size = (0, rn_ui_1.dp)(40), disable
|
|
74
46
|
return;
|
75
47
|
}
|
76
48
|
console.log('pick: ', image);
|
77
|
-
const fileId = yield (
|
78
|
-
const localPath = yield
|
49
|
+
const fileId = yield uploadFile(image.path, image.mime);
|
50
|
+
const localPath = yield moveFile(image.path, fileId + '.jpg', 'avatars');
|
79
51
|
console.log('upload: ', fileId);
|
80
|
-
if (type ===
|
52
|
+
if (type === ConversationType.C2C) {
|
81
53
|
imManager.user.avatars = fileId;
|
82
54
|
// 更新头像b
|
83
55
|
setTimeout(() => __awaiter(void 0, void 0, void 0, function* () {
|
84
56
|
try {
|
85
|
-
yield
|
57
|
+
yield updateUserInfo(Object.assign(Object.assign({}, user), { avatars: fileId }));
|
86
58
|
}
|
87
59
|
catch (e) {
|
88
60
|
console.log('updateUserInfo error: ', e);
|
@@ -91,29 +63,29 @@ const ChatAvatar = ({ id, name, url: fileId, size = (0, rn_ui_1.dp)(40), disable
|
|
91
63
|
}
|
92
64
|
else {
|
93
65
|
// 更新群头像
|
94
|
-
yield
|
66
|
+
yield updateGroupInfo({
|
95
67
|
chatGroupId: id,
|
96
68
|
avatars: fileId,
|
97
69
|
});
|
98
70
|
}
|
99
71
|
// 更新本地资源
|
100
72
|
imManager.updateResource({ url: fileId, localPath });
|
101
|
-
imManager.store.dispatch(
|
73
|
+
imManager.store.dispatch(ConversationActions.updateAvatars(imManager, id, fileId));
|
102
74
|
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(fileId);
|
103
75
|
}
|
104
76
|
});
|
105
77
|
const onPress = () => {
|
106
78
|
if (disabled || editable)
|
107
79
|
return;
|
108
|
-
if (type ===
|
80
|
+
if (type === ConversationType.C2C) {
|
109
81
|
// 跳转到个人详情页
|
110
82
|
navigation.navigate('UserDetail', {
|
111
83
|
userId: id,
|
112
84
|
});
|
113
85
|
}
|
114
86
|
};
|
115
|
-
return (<
|
116
|
-
{ready ? <
|
117
|
-
</
|
87
|
+
return (<TouchableOpacity style={{ width: size, height: size }} disabled={disabled} onPress={onPress} onLongPress={onLongPress}>
|
88
|
+
{ready ? <ChatAvatarId priority={priority} id={id} fileId={fileId} size={size} name={name} defaultAvatar={defaultAvatar}/> : <Avatar icon={<Image style={size ? { width: size, height: size } : {}} source={defaultAvatar}/>}/>}
|
89
|
+
</TouchableOpacity>);
|
118
90
|
};
|
119
|
-
|
91
|
+
export default memo(ChatAvatar);
|
@@ -4,5 +4,5 @@ export interface ChatAvatarIdProps extends ChatAvatarProps {
|
|
4
4
|
id: string;
|
5
5
|
priority?: 'cache' | 'outside';
|
6
6
|
}
|
7
|
-
declare const
|
8
|
-
export default
|
7
|
+
declare const _default: React.MemoExoticComponent<({ id, fileId: fileIdProp, priority, ...ret }: ChatAvatarIdProps) => React.JSX.Element>;
|
8
|
+
export default _default;
|
@@ -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) {
|
@@ -42,37 +18,36 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
42
18
|
}
|
43
19
|
return t;
|
44
20
|
};
|
45
|
-
|
46
|
-
|
47
|
-
};
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
const react_1 = require("react");
|
52
|
-
const init_1 = require("../../init");
|
53
|
-
const ChatAvatarLocal_1 = __importDefault(require("./ChatAvatarLocal"));
|
54
|
-
const user_1 = require("../../api/user");
|
21
|
+
import * as React from 'react';
|
22
|
+
import { memo, useEffect, useState } from "react";
|
23
|
+
import { getImManager } from "../../init";
|
24
|
+
import ChatAvatarLocal from "./ChatAvatarLocal";
|
25
|
+
import { queryUserByIds } from "../../api/user";
|
26
|
+
import { useAvatars } from "../../hooks/useImSelector";
|
55
27
|
const ChatAvatarId = (_a) => {
|
56
28
|
var { id, fileId: fileIdProp, priority } = _a, ret = __rest(_a, ["id", "fileId", "priority"]);
|
57
|
-
const
|
58
|
-
const
|
59
|
-
|
60
|
-
|
61
|
-
(0, react_1.useEffect)(() => {
|
62
|
-
if (priority === 'outside' && fileIdProp) {
|
29
|
+
const [fileId, setFileId] = useState(fileIdProp);
|
30
|
+
const cacheFileId = useAvatars()[id];
|
31
|
+
useEffect(() => {
|
32
|
+
if (priority === 'outside') {
|
63
33
|
setFileId(fileIdProp);
|
64
|
-
|
34
|
+
getImManager().updateAvatar({ avatarsId: id, url: fileIdProp });
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
if (priority === 'cache' && cacheFileId) {
|
38
|
+
setFileId(cacheFileId);
|
65
39
|
return;
|
66
40
|
}
|
67
|
-
|
68
|
-
|
69
|
-
if (!cacheFileId) {
|
41
|
+
getImManager().loadAvatarFromCache(id).then((localId) => __awaiter(void 0, void 0, void 0, function* () {
|
42
|
+
if (!localId) {
|
70
43
|
try {
|
71
44
|
// 通过接口请求头像
|
72
|
-
const { data: [user] } = yield
|
45
|
+
const { data: [user] } = yield queryUserByIds([id]);
|
73
46
|
if (user === null || user === void 0 ? void 0 : user.avatars) {
|
74
|
-
|
75
|
-
|
47
|
+
if (fileId !== user.avatars) {
|
48
|
+
setFileId(user.avatars);
|
49
|
+
getImManager().updateAvatar({ avatarsId: id, url: user.avatars });
|
50
|
+
}
|
76
51
|
}
|
77
52
|
else {
|
78
53
|
setFileId('');
|
@@ -83,10 +58,10 @@ const ChatAvatarId = (_a) => {
|
|
83
58
|
}
|
84
59
|
}
|
85
60
|
else {
|
86
|
-
setFileId(
|
61
|
+
setFileId(localId);
|
87
62
|
}
|
88
63
|
}));
|
89
|
-
}, [id, priority,
|
90
|
-
return (<
|
64
|
+
}, [id, priority, fileIdProp, cacheFileId]);
|
65
|
+
return (<ChatAvatarLocal fileId={fileId} {...ret}/>);
|
91
66
|
};
|
92
|
-
|
67
|
+
export default memo(ChatAvatarId);
|
@@ -5,5 +5,5 @@ export interface ChatAvatarProps {
|
|
5
5
|
name?: string;
|
6
6
|
defaultAvatar?: any;
|
7
7
|
}
|
8
|
-
declare const
|
9
|
-
export default
|
8
|
+
declare const _default: React.MemoExoticComponent<({ fileId, size, name, defaultAvatar }: ChatAvatarProps) => React.JSX.Element>;
|
9
|
+
export default _default;
|
@@ -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,23 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
8
|
});
|
10
9
|
};
|
11
|
-
|
12
|
-
|
13
|
-
};
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
const react_2 = require("react");
|
19
|
-
const init_1 = require("../../init");
|
20
|
-
const react_native_fs_1 = __importDefault(require("react-native-fs"));
|
21
|
-
const LocalImage_1 = __importDefault(require("../../components/LocalImage"));
|
10
|
+
import React, { memo } from 'react';
|
11
|
+
import { Image } from "react-native";
|
12
|
+
import { Avatar } from "@smart-link/rn-ui";
|
13
|
+
import { useEffect, useState } from "react";
|
14
|
+
import { getImManager } from "../../init";
|
15
|
+
import RNFS from "react-native-fs";
|
16
|
+
import LocalImage from "../../components/LocalImage";
|
22
17
|
// 防止重复下载
|
23
18
|
const downloadMap = Object.create(null);
|
24
19
|
const cacheMap = Object.create(null);
|
25
20
|
const ChatAvatarLocal = ({ fileId, size, name, defaultAvatar }) => {
|
26
|
-
const [avatar, setAvatar] =
|
27
|
-
const [ready, setReady] =
|
21
|
+
const [avatar, setAvatar] = useState(fileId ? cacheMap[fileId] : '');
|
22
|
+
const [ready, setReady] = useState(false);
|
28
23
|
const loadAvatar = () => __awaiter(void 0, void 0, void 0, function* () {
|
29
24
|
if (fileId && cacheMap[fileId]) {
|
30
25
|
setAvatar(cacheMap[fileId]);
|
@@ -32,11 +27,11 @@ const ChatAvatarLocal = ({ fileId, size, name, defaultAvatar }) => {
|
|
32
27
|
return;
|
33
28
|
}
|
34
29
|
if (fileId) {
|
35
|
-
const imManager =
|
30
|
+
const imManager = getImManager();
|
36
31
|
const localPath = yield imManager.loadResourceFromCache(fileId);
|
37
32
|
// console.log('loadResourceFromCache: ', localPath)
|
38
33
|
if (localPath) {
|
39
|
-
const exists = yield
|
34
|
+
const exists = yield RNFS.exists(localPath);
|
40
35
|
if (exists) {
|
41
36
|
cacheMap[fileId] = localPath;
|
42
37
|
setAvatar(localPath);
|
@@ -80,18 +75,20 @@ const ChatAvatarLocal = ({ fileId, size, name, defaultAvatar }) => {
|
|
80
75
|
setReady(true);
|
81
76
|
}
|
82
77
|
});
|
83
|
-
|
78
|
+
useEffect(() => {
|
79
|
+
if (!fileId) {
|
80
|
+
setReady(true);
|
81
|
+
return;
|
82
|
+
}
|
84
83
|
loadAvatar().then(_r => { });
|
85
84
|
}, [fileId]);
|
86
|
-
|
87
|
-
|
88
|
-
return (<LocalImage_1.default localPath={avatar} style={size ? { width: size, height: size, borderRadius: size / 2 } : { width: 40, height: 40, borderRadius: 20 }}/>);
|
85
|
+
if (ready && avatar) {
|
86
|
+
return (<LocalImage localPath={avatar} style={size ? { width: size, height: size, borderRadius: size / 2 } : { width: 40, height: 40, borderRadius: 20 }}/>);
|
89
87
|
}
|
90
|
-
else
|
91
|
-
return (<
|
88
|
+
else {
|
89
|
+
return (<Avatar icon={<Image style={{ width: size, height: size }} source={defaultAvatar}/>} style={size ? { width: size, height: size } : {}}>
|
92
90
|
{name === null || name === void 0 ? void 0 : name[0]}
|
93
|
-
</
|
91
|
+
</Avatar>);
|
94
92
|
}
|
95
|
-
return <react_native_1.View style={size ? { width: size, height: size } : { width: 40, height: 40 }}/>;
|
96
93
|
};
|
97
|
-
|
94
|
+
export default memo(ChatAvatarLocal);
|
@@ -1,23 +1,2 @@
|
|
1
|
-
|
2
|
-
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
|
-
};
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
-
exports.default = void 0;
|
21
|
-
var ChatAvatar_1 = require("./ChatAvatar");
|
22
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ChatAvatar_1).default; } });
|
23
|
-
__exportStar(require("./ChatAvatar"), exports);
|
1
|
+
export { default } from './ChatAvatar';
|
2
|
+
export * from './ChatAvatar';
|
@@ -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,15 +7,11 @@ 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
-
const react_1 = __importStar(require("react"));
|
39
|
-
const react_native_fast_image_1 = __importDefault(require("react-native-fast-image"));
|
10
|
+
import React, { memo, useEffect } from 'react';
|
11
|
+
import Image from 'react-native-fast-image';
|
40
12
|
const Favicon = ({ url, size = 40 }) => {
|
41
|
-
const [favicon, setFavicon] =
|
42
|
-
|
13
|
+
const [favicon, setFavicon] = React.useState();
|
14
|
+
useEffect(() => {
|
43
15
|
if (!url)
|
44
16
|
return;
|
45
17
|
getFavicon(url).then((favicon) => {
|
@@ -47,7 +19,7 @@ const Favicon = ({ url, size = 40 }) => {
|
|
47
19
|
setFavicon(favicon);
|
48
20
|
});
|
49
21
|
}, [url]);
|
50
|
-
return (<
|
22
|
+
return (<Image style={{ width: size, height: size }} source={favicon ? { uri: favicon } : {}}/>);
|
51
23
|
};
|
52
24
|
const faviconCache = new Map();
|
53
25
|
const getFavicon = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
@@ -71,4 +43,4 @@ const getFavicon = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
43
|
}
|
72
44
|
return null;
|
73
45
|
});
|
74
|
-
|
46
|
+
export default memo(Favicon);
|
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
3
2
|
var t = {};
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
@@ -10,15 +9,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
10
9
|
}
|
11
10
|
return t;
|
12
11
|
};
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
const react_1 = __importDefault(require("react"));
|
18
|
-
const react_native_1 = require("react-native");
|
19
|
-
const useFormatMsgTime_1 = __importDefault(require("../hooks/useFormatMsgTime"));
|
12
|
+
import React from "react";
|
13
|
+
import { Text } from "react-native";
|
14
|
+
import useFormatMsgTime from "../hooks/useFormatMsgTime";
|
20
15
|
const FormatTimeText = (_a) => {
|
21
16
|
var { time, showDetail = true } = _a, retProps = __rest(_a, ["time", "showDetail"]);
|
22
|
-
return <
|
17
|
+
return <Text {...retProps}>{useFormatMsgTime(time, showDetail)}</Text>;
|
23
18
|
};
|
24
|
-
|
19
|
+
export default FormatTimeText;
|
@@ -1,42 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
27
|
-
const react_1 = __importStar(require("react"));
|
28
|
-
const react_native_1 = require("react-native");
|
1
|
+
import { useTheme } from '@smart-link/rn-ui';
|
2
|
+
import React, { memo } from 'react';
|
3
|
+
import { Text } from 'react-native';
|
29
4
|
const Highlighter = ({ style, searchWord, textToHighlight }) => {
|
30
|
-
const theme =
|
5
|
+
const theme = useTheme();
|
31
6
|
// 高亮显示搜索关键字
|
32
|
-
return (<
|
7
|
+
return (<Text style={style}>
|
33
8
|
{textToHighlight.split(new RegExp(`(${searchWord})`, 'gi')).map((part, index) => {
|
34
|
-
return part.toLowerCase() === searchWord.toLowerCase() ? (<
|
9
|
+
return part.toLowerCase() === searchWord.toLowerCase() ? (<Text key={index} style={{
|
35
10
|
color: theme.primaryColor,
|
36
11
|
}}>
|
37
12
|
{part}
|
38
|
-
</
|
13
|
+
</Text>) : (part);
|
39
14
|
})}
|
40
|
-
</
|
15
|
+
</Text>);
|
41
16
|
};
|
42
|
-
|
17
|
+
export default memo(Highlighter);
|
@@ -1,47 +1,22 @@
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
27
|
-
const react_1 = __importStar(require("react"));
|
28
|
-
const react_native_1 = require("react-native");
|
29
|
-
const IndicatorText = (0, react_1.memo)(props => {
|
30
|
-
const { text, loadingColor = '#fff', fontSize = (0, rn_ui_1.dp)(18), color = '#fff', style } = props;
|
31
|
-
return (<react_native_1.View style={[styles.indicatorText, style]}>
|
32
|
-
<react_native_1.ActivityIndicator size="small" color={loadingColor} animating={true}/>
|
33
|
-
<react_native_1.Text numberOfLines={1} style={[styles.text, { fontSize, color }]}>
|
1
|
+
import { dp } from '@smart-link/rn-ui';
|
2
|
+
import React, { memo } from 'react';
|
3
|
+
import { View, StyleSheet, ActivityIndicator, Text } from 'react-native';
|
4
|
+
const IndicatorText = memo(props => {
|
5
|
+
const { text, loadingColor = '#fff', fontSize = dp(18), color = '#fff', style } = props;
|
6
|
+
return (<View style={[styles.indicatorText, style]}>
|
7
|
+
<ActivityIndicator size="small" color={loadingColor} animating={true}/>
|
8
|
+
<Text numberOfLines={1} style={[styles.text, { fontSize, color }]}>
|
34
9
|
{text}
|
35
|
-
</
|
36
|
-
</
|
10
|
+
</Text>
|
11
|
+
</View>);
|
37
12
|
});
|
38
|
-
const styles =
|
13
|
+
const styles = StyleSheet.create({
|
39
14
|
indicatorText: {
|
40
15
|
flexDirection: 'row',
|
41
16
|
},
|
42
17
|
text: {
|
43
|
-
maxWidth:
|
44
|
-
marginLeft:
|
18
|
+
maxWidth: dp(280),
|
19
|
+
marginLeft: dp(5),
|
45
20
|
},
|
46
21
|
});
|
47
|
-
|
22
|
+
export default IndicatorText;
|
@@ -1,37 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
const react_1 = __importStar(require("react"));
|
27
|
-
const react_native_1 = require("react-native");
|
28
|
-
const file_1 = require("../utils/file");
|
29
|
-
const LocalImage = (0, react_1.memo)(props => {
|
1
|
+
import React, { memo } from 'react';
|
2
|
+
import { Image } from 'react-native';
|
3
|
+
import { toAbsolutePath } from '../utils/file';
|
4
|
+
const LocalImage = memo(props => {
|
30
5
|
const { style, resizeMode, localPath } = props;
|
31
6
|
let source = localPath;
|
32
7
|
if (Object.prototype.toString.call(localPath) === '[object String]') {
|
33
|
-
source = { uri:
|
8
|
+
source = { uri: toAbsolutePath(localPath) };
|
34
9
|
}
|
35
|
-
return <
|
10
|
+
return <Image style={style} resizeMode={resizeMode} source={source}/>;
|
36
11
|
});
|
37
|
-
|
12
|
+
export default LocalImage;
|