@smart-link/rn-im 1.0.11 → 1.0.13

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.
@@ -54,7 +54,7 @@ const ConversationCard = (0, react_1.memo)(props => {
54
54
  <rn_ui_1.Badge text={unreadCount} dot={showPoint}>
55
55
  <ChatAvatar_1.default disabled type={type} id={id} size={(0, rn_ui_1.dp)(48)} name={name} url={avatars}/>
56
56
  </rn_ui_1.Badge>
57
- {status && <react_native_1.View style={styles.status}>
57
+ {status === 'online' && <react_native_1.View style={styles.status}>
58
58
  <MaterialIcons_1.default size={(0, rn_ui_1.dp)(14)} color={status === 'online' ? '#4caf50' : '#616161'} name={status === 'online' ? 'check-circle' : 'not-interested'}/>
59
59
  </react_native_1.View>}
60
60
  </react_native_1.View>
@@ -57,7 +57,7 @@ const OptionAvatars = (0, react_1.memo)(props => {
57
57
  const subCount = isMgr ? 8 : 9;
58
58
  // @ts-ignore
59
59
  return (<react_native_1.View>
60
- {showTitle && (<rn_ui_1.ListRow title={t('groupChatMember')} detail={'(' + (list.length || 0) + ')'} onPress={toMoreMember}/>)}
60
+ {showTitle && (<rn_ui_1.ListRow title={t('groupChatMember')} detail={'(' + (memberTotalCount || 0) + ')'} onPress={toMoreMember}/>)}
61
61
 
62
62
  <react_native_1.View style={[
63
63
  styles.avatarsList,
@@ -15,16 +15,17 @@ const styles_1 = require("../../../components/styles");
15
15
  const { OWNER, MGR, } = im_base_1.MemberLevel;
16
16
  const OptionGroupMoreMember = (props) => {
17
17
  const { groupDetail } = (0, useImSelector_1.useChatGroup)();
18
- const { groupMemberList } = groupDetail;
18
+ const { memberTotalCount } = groupDetail;
19
+ const { allMembers } = (0, useImSelector_1.useMessage)();
19
20
  const [keyword, setKeyword] = (0, react_1.useState)('');
20
21
  const { t } = (0, useTranslation_1.default)();
21
22
  const navigation = (0, rn_ui_1.useNavigation)();
22
23
  (0, react_1.useEffect)(() => {
23
24
  navigation.setOptions({
24
- title: t('groupChatMember') + '(' + groupMemberList.length + ')',
25
+ title: t('groupChatMember') + '(' + memberTotalCount + ')',
25
26
  });
26
- }, [t, navigation, groupMemberList.length]);
27
- const listLineComponent = groupMemberList.length === 0 ? null : <react_native_1.View style={styles.listLine}/>;
27
+ }, [t, navigation, memberTotalCount]);
28
+ const listLineComponent = allMembers.length === 0 ? null : <react_native_1.View style={styles.listLine}/>;
28
29
  const itemSeparatorComponent = () => <react_native_1.View style={[styles.separator]}/>;
29
30
  const keyExtractor = (member) => member.userId;
30
31
  const renderItem = ({ item }) => {
@@ -61,13 +62,13 @@ const OptionGroupMoreMember = (props) => {
61
62
  </react_native_1.TouchableOpacity>);
62
63
  };
63
64
  const list = (0, react_1.useMemo)(() => {
64
- return groupMemberList.slice().reverse().filter((item) => {
65
+ return allMembers.slice().reverse().filter((item) => {
65
66
  if (keyword) {
66
67
  return item.memberName.indexOf(keyword) > -1;
67
68
  }
68
69
  return true;
69
70
  });
70
- }, [groupMemberList, keyword]);
71
+ }, [allMembers, keyword]);
71
72
  return (<rn_ui_1.NavigationPage noPadding>
72
73
  <rn_ui_1.SearchInput value={keyword} onChange={(txt) => {
73
74
  setKeyword(txt);
@@ -27,16 +27,17 @@ const ConversationSetting = ({ navigation }) => {
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
31
  // 设置标题
31
32
  (0, react_1.useEffect)(() => {
32
33
  let newTitle = title;
33
- if ((currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) === im_base_1.ConversationType.C2G && (currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.memberTotalCount)) {
34
- newTitle += `(${currentConversation.memberTotalCount})`;
34
+ if ((currentConversation === null || currentConversation === void 0 ? void 0 : currentConversation.type) === im_base_1.ConversationType.C2G && memberTotalCount) {
35
+ newTitle += `(${memberTotalCount})`;
35
36
  }
36
37
  navigation.setOptions({
37
38
  title: newTitle,
38
39
  });
39
- }, [title, navigation, currentConversation]);
40
+ }, [title, navigation, currentConversation, memberTotalCount]);
40
41
  if (!currentConversation) {
41
42
  return null;
42
43
  }
@@ -57,7 +58,7 @@ const ConversationSetting = ({ navigation }) => {
57
58
  imManager.clearMessages(currentConversation.id);
58
59
  }, t);
59
60
  };
60
- const { id, type, name, avatars, enableNoDisturb = 'off', enableTop = 'off', notice = '', enableInviteValidate = 'off', memberLevel = MEMBER, memberTotalCount = 0, groupType, } = currentConversation;
61
+ const { id, type, name, avatars, enableNoDisturb = 'off', enableTop = 'off', notice = '', enableInviteValidate = 'off', memberLevel = MEMBER, groupType, } = currentConversation;
61
62
  const groupMemberList = (_a = groupDetail === null || groupDetail === void 0 ? void 0 : groupDetail.groupMemberList.slice().reverse()) !== null && _a !== void 0 ? _a : [];
62
63
  console.log('type: ', type, '[memberLevel]', memberLevel);
63
64
  const isMgr = memberLevel === MGR || memberLevel === OWNER;
@@ -147,7 +148,7 @@ const ConversationSetting = ({ navigation }) => {
147
148
  })
148
149
  .splice(0, MAX_SHOW_MEMBER_COUNT);
149
150
  content = (<>
150
- <OptionAvatars_1.default list={avatarList} showTitle showAdd showMore={isMgr ? avatarList.length > 8 : avatarList.length > 9} isMgr={isMgr} addUser={() => {
151
+ <OptionAvatars_1.default list={avatarList} showTitle memberTotalCount={memberTotalCount} showAdd showMore={isMgr ? avatarList.length > 8 : avatarList.length > 9} isMgr={isMgr} addUser={() => {
151
152
  // 添加成员
152
153
  (0, init_1.getImManager)().store.dispatch((0, contact_slice_1.startAddMember)());
153
154
  navigation.navigate('ChooseContact', {
@@ -155,6 +156,7 @@ const ConversationSetting = ({ navigation }) => {
155
156
  checkMode: 'multi',
156
157
  });
157
158
  }} removeUser={removeUser} toMoreMember={() => {
159
+ (0, init_1.getImManager)().store.dispatch(im_base_1.MessagePanelActions.loadAllMembers(id));
158
160
  navigation.navigate('OptionGroupMoreMember');
159
161
  }}/>
160
162
  <rn_ui_1.Space size={'m'}/>
@@ -45,24 +45,35 @@ const UploadProgress_1 = __importDefault(require("../UploadProgress"));
45
45
  const init_1 = require("../../../../init");
46
46
  const PayloadWrapper_1 = __importDefault(require("./PayloadWrapper"));
47
47
  const file_icon_1 = require("../../../../utils/file-icon");
48
+ const useTranslation_1 = __importDefault(require("../../../../hooks/useTranslation"));
48
49
  const PayloadFile = ({ payload, messageSeq, direction, showArrow = true, messageStatus, sendSize, style, onLongPress }) => {
49
50
  const ext = payload.filename.split('.').pop();
50
51
  const Icon = (0, file_icon_1.findSvgIcon)(ext);
51
52
  const path = (0, react_1.useRef)('');
52
53
  const downloading = (0, react_1.useRef)(false);
54
+ const { t } = (0, useTranslation_1.default)();
53
55
  const [download, setDownload] = (0, react_1.useState)({
54
56
  progress: 0,
55
57
  status: 'pending',
56
58
  });
59
+ const openWithLocal = (path) => __awaiter(void 0, void 0, void 0, function* () {
60
+ try {
61
+ yield react_native_file_viewer_1.default.open(path);
62
+ }
63
+ catch (e) {
64
+ rn_ui_1.Toast.warning(t('fileOpenFail'));
65
+ }
66
+ });
57
67
  return (<PayloadWrapper_1.default direction={direction} showArrow={showArrow} onLongPress={onLongPress} style={[style, styles.file]} onPress={() => __awaiter(void 0, void 0, void 0, function* () {
58
68
  if (payload.localPath || path.current) {
59
- yield react_native_file_viewer_1.default.open((payload.localPath || path.current));
69
+ yield openWithLocal((payload.localPath || path.current));
60
70
  }
61
71
  else if (payload.fileId) {
62
72
  if (downloading.current)
63
73
  return;
64
74
  downloading.current = true;
65
- const localPath = yield (0, init_1.getImManager)().download({
75
+ const imManager = (0, init_1.getImManager)();
76
+ const localPath = yield imManager.download({
66
77
  fileId: payload.fileId,
67
78
  resourceType: 'file',
68
79
  filename: payload.filename,
@@ -83,14 +94,14 @@ const PayloadFile = ({ payload, messageSeq, direction, showArrow = true, message
83
94
  messageSeq,
84
95
  payload: Object.assign(Object.assign({}, payload), { localPath: localPath }),
85
96
  });
86
- yield react_native_file_viewer_1.default.open(localPath);
97
+ yield openWithLocal(localPath);
87
98
  }
88
99
  })}>
89
100
  <react_native_1.View style={{ flexDirection: 'row', alignItems: 'center' }}>
90
101
  <Icon style={styles.fileIcon}/>
91
102
  <react_native_1.View style={{ flex: 1 }}>
92
- <react_native_1.Text>{payload.filename}</react_native_1.Text>
93
- <react_native_1.Text style={styles.size}>{(0, file_1.numberToFileSize)(payload.size)}</react_native_1.Text>
103
+ <react_native_1.Text numberOfLines={1} ellipsizeMode="middle">{payload.filename}</react_native_1.Text>
104
+ <react_native_1.Text style={styles.size}>{(0, file_1.numberToFileSize)(payload.size)}{payload.localPath ? t('downloaded') : ''}</react_native_1.Text>
94
105
  </react_native_1.View>
95
106
  </react_native_1.View>
96
107
  <UploadProgress_1.default show={download.status === 'downloading'} width={200} sendSize={download.progress} totalSize={payload.size}/>
@@ -57,7 +57,7 @@ const PayloadMultiple = (0, react_1.memo)(({ payload, direction, showArrow = tru
57
57
  {messages.map((message, index) => {
58
58
  return message === 'more' ? (<react_native_1.Text key={index} style={styles.itemTextMore}>
59
59
  ......
60
- </react_native_1.Text>) : (<react_native_1.Text key={index} style={styles.itemText} numberOfLines={1}>
60
+ </react_native_1.Text>) : (<react_native_1.Text key={index} style={styles.itemText} numberOfLines={1} ellipsizeMode="middle">
61
61
  {message.messageFromName + ': ' + (0, im_base_1.buildSimpleText)(imManager, message.payloadType, message.payload)}
62
62
  </react_native_1.Text>);
63
63
  })}
@@ -35,6 +35,7 @@ const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"
35
35
  const dayjs_1 = __importDefault(require("dayjs"));
36
36
  const ReceiptBack = ({ message }) => {
37
37
  const { t } = (0, useTranslation_1.default)();
38
+ // console.log('ReceiptBack: ', message.receiptBackList.length, message.receiptBackList);
38
39
  return (<react_native_1.View style={styles.content}>
39
40
  <react_native_1.View style={{ flexDirection: 'row' }}>
40
41
  <react_native_1.Text style={[styles.text, { width: (0, rn_ui_1.dp)(165) }]}>
@@ -54,6 +55,8 @@ const ReceiptBack = ({ message }) => {
54
55
  statusText = t('statusArrived');
55
56
  break;
56
57
  }
58
+ default:
59
+ return null;
57
60
  }
58
61
  return (<react_native_1.View key={index} style={{ flexDirection: 'row' }}>
59
62
  <react_native_1.Text style={[styles.text, { width: (0, rn_ui_1.dp)(165) }]}>
@@ -55,7 +55,13 @@ const uploadFile = (filePath, type, onProgress) => __awaiter(void 0, void 0, voi
55
55
  });
56
56
  console.log('uploadFile: ', resp);
57
57
  try {
58
- return JSON.parse(resp.body).data;
58
+ let body = JSON.parse(resp.body);
59
+ if (body.data) {
60
+ return body.data;
61
+ }
62
+ else {
63
+ throw new Error(body.codeMsg);
64
+ }
59
65
  }
60
66
  catch (e) {
61
67
  console.log('uploadFile error: ', e);
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@smart-link/rn-im",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
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
9
  "emoji-regex": "^10.4.0",
10
- "@smart-link/im-base": "^1.0.11"
10
+ "@smart-link/im-base": "^1.0.13"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@react-native/eslint-config": "0.73.2",