Skip to content

Commit 0ac7159

Browse files
authored
Merge pull request #78 from dogbutcat/master
FIX #77: getAllUnreadCount返回数据结构不一致
2 parents f898c50 + 073f11b commit 0ac7159

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

android/src/io/jchat/android/Constant.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public class Constant {
105105
static final String PROGRESS = "progress";
106106
public static final String UNRECEIPT_COUNT = "unreceiptCount";
107107
public static final String IS_DESCEND = "isDescend";
108+
public static final String UNKNOW = "unknow";
108109

109110
/**
110111
* ChatRoom

android/src/io/jchat/android/JMessageModule.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,10 +1710,10 @@ public void createChatRoomConversation(String roomId, Callback success) {
17101710
*/
17111711
@ReactMethod
17121712
public void getAllUnreadCount(Callback success) {
1713-
WritableMap map = Arguments.createMap();
1713+
// WritableMap map = Arguments.createMap();
17141714
int count = JMessageClient.getAllUnReadMsgCount();
1715-
map.putInt("count", count);
1716-
success.invoke(map);
1715+
// map.putInt("count", count);
1716+
success.invoke(count);
17171717
}
17181718

17191719
@ReactMethod

android/src/io/jchat/android/utils/ResultUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,9 @@ public static WritableMap toJSObject(Message msg) {
243243
result.putString(Constant.EVENT_TYPE, "group_type_changed");
244244
break;
245245
}
246+
break;
246247
default:
247-
return null;
248+
result.putString(Constant.TYPE, Constant.UNKNOW);
248249
}
249250
} catch (Exception e) {
250251
e.printStackTrace();

document/API.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import JMessage from 'jmessage-react-plugin';
3333
- [applyJoinGroup](#applyjoingroup)
3434
- [processApplyJoinGroup](#processapplyjoingroup)
3535
- [dissolveGroup](#dissolvegroup)
36+
- [getGroupIds](#getgroupids)
37+
- [getGroupInfo](#getgroupinfo)
3638
- [聊天](#聊天)
3739
- [createSendMessage](#createsendmessage)
3840
- [sendMessage](#sendmessage)
@@ -55,6 +57,7 @@ import JMessage from 'jmessage-react-plugin';
5557
- [exitConversation](#exitconversation)
5658
- [getConversation](#getconversation)
5759
- [getConversations](#getconversations)
60+
- [getAllUnreadCount](#getallunreadcount)
5861
- [resetUnreadMessageCount](#resetunreadmessagecount)
5962
- [聊天室](#聊天室)
6063
- [getChatRoomListByApp](#getchatroomlistbyapp)
@@ -397,6 +400,65 @@ JMessage.dissolveGroup({ groupId: 'group_id' },
397400
#### 参数说明
398401
- groupId (string): 要解散的群组 id。
399402

403+
### getGroupIds
404+
405+
获取当前用户群组
406+
407+
#### 示例
408+
```js
409+
JMessage.getGroupIds(
410+
(result) => {
411+
/**
412+
* result {Array[Number]} 当前用户所加入的群组的groupID的list
413+
*/
414+
}, (error) => {
415+
/**
416+
* error {Object} {code:Number,desc:String}
417+
*/
418+
}
419+
)
420+
```
421+
422+
#### 参数说明
423+
424+
425+
426+
### getGroupInfo
427+
428+
根据群组id获取群组信息
429+
430+
#### 示例
431+
432+
```js
433+
JMessage.getGroupInfo(
434+
{ id: "1234567" },
435+
(result) => {
436+
/**
437+
* result {Object} 群组信息
438+
{
439+
desc:""
440+
id:"1234567"
441+
isBlocked:false
442+
isNoDisturb:false
443+
level:0
444+
maxMemberCount:500
445+
name:"China no 1"
446+
owner:"1234"
447+
ownerAppKey:"abcdef..."
448+
type:"group" // or single
449+
}
450+
*/
451+
}, (error) => {
452+
/**
453+
* error {Object} {code:Number,desc:String}
454+
*/
455+
}
456+
)
457+
```
458+
459+
#### 参数说明
460+
461+
- id(string): 指定群组
400462

401463
### addGroupAdmins
402464

@@ -1157,6 +1219,28 @@ JMessage.getConversations((conArr) => { // conArr: 会话数组。
11571219
})
11581220
```
11591221
1222+
### getAllUnreadCount
1223+
1224+
当前用户所有会话的未读消息总数
1225+
1226+
- ⚠️ 截止jmessage-sdk-2.6.1 返回的数量为会话列表的未读总数即包括了被移除的群组、好友的未读.
1227+
1228+
#### 示例
1229+
1230+
```js
1231+
JMessage.getAllUnreadCount(
1232+
(result) => {
1233+
/**
1234+
* result {Number} 当前用户所有会话的未读消息总数
1235+
*/
1236+
}
1237+
)
1238+
```
1239+
1240+
#### 参数说明
1241+
1242+
1243+
11601244
### resetUnreadMessageCount
11611245
11621246
重置会话的未读消息数。

0 commit comments

Comments
 (0)