@smart-link/rn-im 1.0.18 → 1.0.20

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.
@@ -0,0 +1,3 @@
1
+ import { IPayload } from "@smart-link/im-base";
2
+ export declare function useDownloadImgSource(payload: IPayload): string | File | undefined;
3
+ export default function useDownloadSource(payload: IPayload): string | File | undefined;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.useDownloadImgSource = void 0;
13
+ const react_1 = require("react");
14
+ const init_1 = require("../init");
15
+ function useDownload({ fileId, localPath, filename }) {
16
+ const [local, setLocal] = (0, react_1.useState)(localPath);
17
+ (0, react_1.useEffect)(() => {
18
+ let cancel = false;
19
+ const load = () => __awaiter(this, void 0, void 0, function* () {
20
+ const imManager = (0, init_1.getImManager)();
21
+ if (!localPath && fileId) {
22
+ const tmp = yield imManager.loadResourceFromCache(fileId);
23
+ if (tmp) {
24
+ !cancel && setLocal(tmp);
25
+ return;
26
+ }
27
+ const file = yield imManager.download({
28
+ fileId,
29
+ filename: filename || fileId,
30
+ resourceType: 'file',
31
+ });
32
+ yield imManager.updateResource({
33
+ url: fileId,
34
+ localPath: file,
35
+ });
36
+ if (cancel) {
37
+ return;
38
+ }
39
+ setLocal(file);
40
+ }
41
+ });
42
+ load();
43
+ return () => {
44
+ cancel = true;
45
+ };
46
+ }, [localPath, fileId, filename]);
47
+ return local;
48
+ }
49
+ function useDownloadImgSource(payload) {
50
+ const { imageName, imagePath, imageFileId } = payload;
51
+ return useDownload({
52
+ localPath: imagePath,
53
+ fileId: imageFileId,
54
+ filename: imageName,
55
+ resourceType: 'picture'
56
+ });
57
+ }
58
+ exports.useDownloadImgSource = useDownloadImgSource;
59
+ function useDownloadSource(payload) {
60
+ const { localPath, fileId, filename, } = payload;
61
+ return useDownload({
62
+ localPath,
63
+ fileId,
64
+ filename,
65
+ resourceType: 'picture',
66
+ });
67
+ }
68
+ exports.default = useDownloadSource;
@@ -45,13 +45,12 @@ const react_1 = __importStar(require("react"));
45
45
  const react_native_1 = require("react-native");
46
46
  const GroupTransfer = ({ navigation }) => {
47
47
  const { t } = (0, useTranslation_1.default)();
48
- const { groupDetail } = (0, useImSelector_1.useChatGroup)();
49
- const { groupMemberList } = groupDetail;
48
+ const { allMembers } = (0, useImSelector_1.useConversation)();
50
49
  const [checkedMember, setCheckedMember] = (0, react_1.useState)(null);
51
50
  const [keyword, setKeyword] = (0, react_1.useState)('');
52
51
  const list = (0, react_1.useMemo)(() => {
53
- return groupMemberList === null || groupMemberList === void 0 ? void 0 : groupMemberList.filter(item => item.memberLevel !== 'owner');
54
- }, [groupMemberList]);
52
+ return allMembers === null || allMembers === void 0 ? void 0 : allMembers.filter(item => item.memberLevel !== 'owner');
53
+ }, [allMembers]);
55
54
  (0, react_1.useEffect)(() => {
56
55
  navigation.setOptions({
57
56
  title: t('chooseNewOwner'),
@@ -16,7 +16,7 @@ const { OWNER, MGR, } = im_base_1.MemberLevel;
16
16
  const OptionGroupMoreMember = (props) => {
17
17
  const { groupDetail } = (0, useImSelector_1.useChatGroup)();
18
18
  const { memberTotalCount } = groupDetail;
19
- const { allMembers } = (0, useImSelector_1.useMessage)();
19
+ const { allMembers } = (0, useImSelector_1.useConversation)();
20
20
  const [keyword, setKeyword] = (0, react_1.useState)('');
21
21
  const { t } = (0, useTranslation_1.default)();
22
22
  const navigation = (0, rn_ui_1.useNavigation)();
@@ -62,7 +62,7 @@ const OptionGroupMoreMember = (props) => {
62
62
  </react_native_1.TouchableOpacity>);
63
63
  };
64
64
  const list = (0, react_1.useMemo)(() => {
65
- const allMembersData = allMembers.slice().reverse().filter((item) => {
65
+ const allMembersData = allMembers.filter((item) => {
66
66
  if (keyword) {
67
67
  return item.memberName.indexOf(keyword) > -1;
68
68
  }
@@ -22,12 +22,12 @@ const { LIAISON } = im_base_1.GroupType;
22
22
  // 最大显示人数
23
23
  const MAX_SHOW_MEMBER_COUNT = 23;
24
24
  const ConversationSetting = ({ navigation }) => {
25
- var _a, _b;
26
25
  const { t } = (0, useTranslation_1.default)();
26
+ // const {allMembers} = useMessage();
27
27
  const { currentConversation } = (0, useImSelector_1.useConversation)();
28
28
  const { groupDetail } = (0, useImSelector_1.useChatGroup)();
29
29
  const title = t('chatSetting');
30
- const { memberTotalCount = 0 } = groupDetail || {};
30
+ const { memberTotalCount = 0, groupMemberList = [] } = groupDetail || {};
31
31
  // 设置标题
32
32
  (0, react_1.useEffect)(() => {
33
33
  let newTitle = title;
@@ -59,8 +59,7 @@ const ConversationSetting = ({ navigation }) => {
59
59
  }, t);
60
60
  };
61
61
  const { id, type, name, avatars, enableNoDisturb = 'off', enableTop = 'off', notice = '', enableInviteValidate = 'off', memberLevel = MEMBER, groupType, } = currentConversation;
62
- const groupMemberList = (_a = groupDetail === null || groupDetail === void 0 ? void 0 : groupDetail.groupMemberList.slice().reverse()) !== null && _a !== void 0 ? _a : [];
63
- console.log('type: ', type, '[memberLevel]', memberLevel);
62
+ // console.log('type: ', type , '[memberLevel]', memberLevel);
64
63
  const isMgr = memberLevel === MGR || memberLevel === OWNER;
65
64
  // 离开群组
66
65
  const leaveGroup = () => {
@@ -147,23 +146,6 @@ const ConversationSetting = ({ navigation }) => {
147
146
  };
148
147
  })
149
148
  .splice(0, MAX_SHOW_MEMBER_COUNT);
150
- let fMaster = groupMemberList.find(item => item.memberLevel === OWNER);
151
- // 假设 fMaster 是要插入的对象,且它有一个唯一标识,比如 userId
152
- if (fMaster) {
153
- const fMasterWithRequiredFields = {
154
- userId: fMaster.userId,
155
- userName: (_b = fMaster.memberName) !== null && _b !== void 0 ? _b : '',
156
- avatars: fMaster.memberAvatars,
157
- memberLevel: fMaster.memberLevel,
158
- };
159
- // 先移除已存在的群主
160
- const existingIndex = avatarList.findIndex(item => item.userId === (fMaster === null || fMaster === void 0 ? void 0 : fMaster.userId));
161
- if (existingIndex > -1) {
162
- avatarList.splice(existingIndex, 1);
163
- }
164
- // 插入群主
165
- avatarList.unshift(fMasterWithRequiredFields);
166
- }
167
149
  content = (<>
168
150
  <OptionAvatars_1.default list={avatarList} showTitle memberTotalCount={memberTotalCount} showAdd showMore={isMgr ? avatarList.length > 8 : avatarList.length > 9} isMgr={isMgr} addUser={() => {
169
151
  // 添加成员
@@ -173,7 +155,6 @@ const ConversationSetting = ({ navigation }) => {
173
155
  checkMode: 'multi',
174
156
  });
175
157
  }} removeUser={removeUser} toMoreMember={() => {
176
- (0, init_1.getImManager)().store.dispatch(im_base_1.MessagePanelActions.loadAllMembers(id));
177
158
  navigation.navigate('OptionGroupMoreMember');
178
159
  }}/>
179
160
  <rn_ui_1.Space size={'m'}/>
@@ -37,10 +37,11 @@ const im_base_1 = require("@smart-link/im-base");
37
37
  const init_1 = require("../../init");
38
38
  const ChooseMember = ({ navigation, route: { params } }) => {
39
39
  const { groupDetail } = (0, useImSelector_1.useChatGroup)();
40
+ const { allMembers } = (0, useImSelector_1.useConversation)();
40
41
  const [keyword, seKeyword] = (0, react_1.useState)('');
41
42
  const [checked, setChecked] = (0, react_1.useState)([]);
42
43
  const { t } = (0, useTranslation_1.default)();
43
- const { groupMemberList, memberLevel } = groupDetail;
44
+ const { memberLevel } = groupDetail;
44
45
  const imManager = (0, init_1.getImManager)();
45
46
  const list = (0, react_1.useMemo)(() => {
46
47
  if (params.atOther && ['owner', 'mgr'].includes(memberLevel)) {
@@ -49,12 +50,12 @@ const ChooseMember = ({ navigation, route: { params } }) => {
49
50
  userId: 'allMembers',
50
51
  memberName: t('allMembers'),
51
52
  },
52
- ].concat(groupMemberList.filter(item => item.userId !== imManager.user.userId && (keyword ? item.memberName.includes(keyword) : true)));
53
+ ].concat(allMembers.filter(item => item.userId !== imManager.user.userId && (keyword ? item.memberName.includes(keyword) : true)));
53
54
  }
54
55
  else {
55
- return groupMemberList.filter(item => item.userId !== imManager.user.userId && (keyword ? item.memberName.includes(keyword) : true));
56
+ return allMembers.filter(item => item.userId !== imManager.user.userId && (keyword ? item.memberName.includes(keyword) : true));
56
57
  }
57
- }, [params.atOther, groupMemberList, keyword]);
58
+ }, [params.atOther, allMembers, keyword]);
58
59
  (0, react_1.useEffect)(() => {
59
60
  navigation.setOptions({
60
61
  headerLeft({ tintColor }) {
@@ -200,10 +200,10 @@ class RestoreTaskItem extends TaskItem {
200
200
  console.log('insertMessage error: ', e);
201
201
  }
202
202
  }
203
- callback(1);
204
203
  return message;
205
204
  }))();
206
205
  }));
206
+ callback(1);
207
207
  });
208
208
  }
209
209
  }
@@ -41,6 +41,7 @@ const LocalImage_1 = __importDefault(require("../../../components/LocalImage"));
41
41
  const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
42
42
  const init_1 = require("../../../init");
43
43
  const PayloadFile_1 = __importDefault(require("./Payload/PayloadFile"));
44
+ const useDownloadSource_1 = __importStar(require("../../../hooks/useDownloadSource"));
44
45
  const voiceLeft = require('../../../../assets/voice-left.png');
45
46
  const { width } = react_native_1.Dimensions.get('window');
46
47
  exports.QuoteTextMix = (0, react_1.memo)(props => {
@@ -56,9 +57,10 @@ exports.QuoteTextMix = (0, react_1.memo)(props => {
56
57
  });
57
58
  exports.QuotePicture = (0, react_1.memo)(props => {
58
59
  const { quoteTitle, quoteMessage, quoteStyle, color, textStyle, borderColor, backgroundColor, onPressQuote } = props;
59
- const { height, width, localPath } = quoteMessage.payload;
60
+ const { height, width } = quoteMessage.payload;
60
61
  const theme = (0, rn_ui_1.useTheme)();
61
62
  console.log('QuotePicture', quoteMessage);
63
+ const localImg = (0, useDownloadSource_1.default)(quoteMessage.payload);
62
64
  const sizeStyle = (0, golden_rectangle_1.calculate)(height || 100, width || 61.8, 100);
63
65
  return (<react_native_1.TouchableOpacity activeOpacity={0.5} onPress={onPressQuote} style={[quoteStyle, styles.leftBorder, { backgroundColor: (0, color_1.dark)(color, 6) }]}>
64
66
  <react_native_1.Text style={[textStyle, styles.replyUserName]}>
@@ -66,7 +68,7 @@ exports.QuotePicture = (0, react_1.memo)(props => {
66
68
  {' : '}
67
69
  </react_native_1.Text>
68
70
  <react_native_1.View style={styles.h5}/>
69
- {(!localPath || localPath === '') && (<react_native_1.View style={[
71
+ {(!localImg) && (<react_native_1.View style={[
70
72
  styles.pictureEmpty,
71
73
  Object.assign({ backgroundColor,
72
74
  borderColor }, sizeStyle),
@@ -75,22 +77,23 @@ exports.QuotePicture = (0, react_1.memo)(props => {
75
77
  <react_native_1.ActivityIndicator color={theme.primaryColor} animating={true}/>
76
78
  </react_native_1.View>)}
77
79
 
78
- {localPath && localPath !== '' && (<LocalImage_1.default style={sizeStyle} resizeMode="cover" localPath={localPath}/>)}
80
+ {localImg && (<LocalImage_1.default style={sizeStyle} resizeMode="cover" localPath={localImg}/>)}
79
81
  </react_native_1.TouchableOpacity>);
80
82
  });
81
83
  exports.QuoteVideo = (0, react_1.memo)(props => {
82
84
  const { quoteTitle, quoteMessage, quoteStyle, color, textStyle, borderColor, backgroundColor, onPressQuote } = props;
83
- const { duration, height, width, imagePath } = quoteMessage.payload;
85
+ const { duration, height, width } = quoteMessage.payload;
84
86
  const theme = (0, rn_ui_1.useTheme)();
85
87
  console.log('QuoteVideo: ', quoteMessage);
86
88
  const sizeStyle = (0, golden_rectangle_1.calculate)(height, width);
89
+ const localImg = (0, useDownloadSource_1.useDownloadImgSource)(quoteMessage.payload);
87
90
  return (<react_native_1.TouchableOpacity activeOpacity={0.5} onPress={onPressQuote} style={[quoteStyle, styles.leftBorder, { backgroundColor: (0, color_1.dark)(color, 6) }]}>
88
91
  <react_native_1.Text style={[textStyle, styles.replyUserName]}>
89
92
  {quoteTitle}
90
93
  {' : '}
91
94
  </react_native_1.Text>
92
95
  <react_native_1.View style={styles.h5}/>
93
- {(!imagePath || imagePath === '') && (<react_native_1.View style={[
96
+ {(!localImg) && (<react_native_1.View style={[
94
97
  styles.pictureEmpty,
95
98
  Object.assign({ backgroundColor,
96
99
  borderColor }, sizeStyle),
@@ -99,8 +102,8 @@ exports.QuoteVideo = (0, react_1.memo)(props => {
99
102
  <react_native_1.ActivityIndicator color={theme.primaryColor} animating={true}/>
100
103
  </react_native_1.View>)}
101
104
 
102
- {imagePath && imagePath !== '' && (<react_native_1.View>
103
- <LocalImage_1.default style={sizeStyle} resizeMode="cover" localPath={imagePath}/>
105
+ {localImg && (<react_native_1.View style={{ width: sizeStyle.width }}>
106
+ <LocalImage_1.default style={sizeStyle} resizeMode="cover" localPath={localImg}/>
104
107
  <react_native_1.View style={styles.playView}>
105
108
  <AntDesign_1.default size={30} name="playcircleo" color="#fff"/>
106
109
  </react_native_1.View>
@@ -7,7 +7,6 @@ exports.chatReducers = void 0;
7
7
  const video_slice_1 = __importDefault(require("./video/video.slice"));
8
8
  const contact_slice_1 = __importDefault(require("./contact/contact.slice"));
9
9
  const panel_slice_1 = __importDefault(require("./panel/panel.slice"));
10
- // @ts-ignore
11
10
  exports.chatReducers = {
12
11
  'chat/video': video_slice_1.default,
13
12
  'chat/contact': contact_slice_1.default,
@@ -35,6 +35,5 @@ const videoSlice = (0, toolkit_1.createSlice)({
35
35
  }
36
36
  }
37
37
  });
38
- // @ts-ignore;
39
38
  _a = videoSlice.actions, exports.showVideoPlayer = _a.showVideoPlayer, exports.cancelVideoPlayer = _a.cancelVideoPlayer, exports.setVideoDownloadProgress = _a.setVideoDownloadProgress, exports.setShowVideoPlay = _a.setShowVideoPlay;
40
39
  exports.default = videoSlice.reducer;
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@smart-link/rn-im",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "dependencies": {
7
7
  "color": "^5.0.0",
8
8
  "lodash-es": "^4.17.21",
9
- "emoji-regex": "^10.4.0",
10
- "@smart-link/im-base": "^1.0.16"
9
+ "emoji-regex": "^10.4.0"
11
10
  },
12
11
  "devDependencies": {
13
12
  "@react-native/eslint-config": "0.73.2",
@@ -21,7 +20,8 @@
21
20
  "rimraf": "^6.0.1",
22
21
  "tsc-alias": "^1.8.10",
23
22
  "typescript": "5.0.4",
24
- "react-native": "^0.73.0"
23
+ "react-native": "^0.73.0",
24
+ "redux": "^4.2.1"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@baronha/react-native-photo-editor": "1.1.6",
@@ -64,7 +64,7 @@
64
64
  "redux": "^4.2.1",
65
65
  "redux-thunk": "^2.4.2",
66
66
  "@smart-link/rn-ui": "^1.0.6",
67
- "@smart-link/rn-base": "^1.0.7"
67
+ "@smart-link/im-base": "^1.0.20"
68
68
  },
69
69
  "files": [
70
70
  "dist/**",
@@ -74,7 +74,7 @@
74
74
  "scripts": {
75
75
  "clean": "rimraf ./dist",
76
76
  "build": "pnpm run clean && tsc && tsc-alias",
77
- "build:watch": "concurrently \"tsc -w\" \"tsc-alias -w\"",
77
+ "build:watch": "tsc && concurrently \"tsc -w\" \"tsc-alias -w\"",
78
78
  "release": "pnpm build && pnpm publish --tag latest --access public --no-git-checks"
79
79
  }
80
80
  }