Skip to content

Commit b1b1034

Browse files
KenChoiKenChoi
authored andcommitted
getHistoryMessages add field isDescend
1 parent 47dffb9 commit b1b1034

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.File;
2626
import java.io.FileNotFoundException;
2727
import java.util.ArrayList;
28+
import java.util.Collections;
2829
import java.util.HashSet;
2930
import java.util.List;
3031
import java.util.Set;
@@ -508,7 +509,15 @@ public void getHistoryMessages(ReadableMap map, Callback success, Callback fail)
508509
int from = map.getInt(Constant.FROM);
509510
int limit = map.getInt(Constant.LIMIT);
510511
List<Message> messages = conversation.getMessagesFromNewest(from, limit);
512+
// Is descend 为 false 则按照时间顺序排列,2.3.5 新增字段
513+
if (map.hasKey(Constant.IS_DESCEND)) {
514+
boolean isDescend = map.getBoolean(Constant.IS_DESCEND);
515+
if (!isDescend) {
516+
Collections.reverse(messages);
517+
}
518+
}
511519
success.invoke(ResultUtils.toJSArray(messages));
520+
512521
} catch (Exception e) {
513522
e.printStackTrace();
514523
mJMessageUtils.handleError(fail, ERR_CODE_PARAMETER, "Unexpected error");

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ export default class JMessage {
322322
* 'appKey': String, // 当 type = single 时,用于指定对象所属应用的 appKey。如果为空,默认为当前应用。
323323
* 'from': Number, // 开始的消息下标。
324324
* 'limit': Number // 要获取的消息数。比如当 from = 0, limit = 10 时,是获取第 0 - 9 条历史消息。
325+
* 'isDescend': Bool // 2.3.5 新增。如果设置为 true,则返回的消息列表按照时间降序排列,反之,按照时间顺序排列。
325326
* }
326327
* @param {function} success = function (messageArray)) {} // 以参数形式返回历史消息对象数组
327328
* @param {function} error = function ({'code': '错误码', 'description': '错误信息'}) {}

0 commit comments

Comments
 (0)