Skip to content

Commit bed77e4

Browse files
authored
Merge pull request #49 from jpush/dev
Dev
2 parents c1ccd80 + 75032a7 commit bed77e4

File tree

12 files changed

+37
-20
lines changed

12 files changed

+37
-20
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public class Constant {
9393
static final String MESSAGE_ARRAY = "messageArray";
9494
static final String PROGRESS = "progress";
9595
public static final String UNRECEIPT_COUNT = "unreceiptCount";
96+
public static final String IS_DESCEND = "isDescend";
9697
/**
9798
* ChatRoom
9899
*/

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,6 +509,14 @@ 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+
boolean isDescend = false;
514+
if (map.hasKey(Constant.IS_DESCEND)) {
515+
isDescend = map.getBoolean(Constant.IS_DESCEND);
516+
}
517+
if (!isDescend) {
518+
Collections.reverse(messages);
519+
}
511520
success.invoke(ResultUtils.toJSArray(messages));
512521
} catch (Exception e) {
513522
e.printStackTrace();

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public static WritableMap toJSObject(GroupInfo groupInfo) {
109109
result.putString(Constant.DESC, groupInfo.getGroupDescription());
110110
result.putInt(Constant.LEVEL, groupInfo.getGroupLevel());
111111
result.putString(Constant.OWNER, groupInfo.getGroupOwner());
112-
result.putString(Constant.AVATAR_THUMB_PATH, groupInfo.getAvatarFile().getAbsolutePath());
112+
if (groupInfo.getAvatarFile() != null) {
113+
result.putString(Constant.AVATAR_THUMB_PATH, groupInfo.getAvatarFile().getAbsolutePath());
114+
}
113115
result.putString(Constant.OWNER_APP_KEY, groupInfo.getOwnerAppkey());
114116
result.putInt(Constant.MAX_MEMBER_COUNT, groupInfo.getMaxMemberCount());
115117
result.putBoolean(Constant.IS_NO_DISTURB, groupInfo.getNoDisturb() == 1);

document/API.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ JMessage.getHistoryMessages({ type: 'single', username: 'username',
699699
- groupId: 对象群组 id。当 `type` 为 'group' 时,`groupId` 为必填。
700700
- from: 第一条消息对应的下标,起始为 0。
701701
- limit: 消息数。当 from = 0 并且 limit = -1 时,返回所有的历史消息。
702+
- isDescend: 是否降序(消息时间戳从大到小排序),默认为 false。
702703

703704
### downloadOriginalImage
704705

example/android/app/app.iml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,17 @@
8484
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
8585
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
8686
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
87-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
8887
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8988
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
90-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
91-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
9289
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
93-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
94-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
95-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
9690
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
97-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
9891
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
9992
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
10093
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
101-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
102-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/sourceFolderJavaResources" />
10394
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
10495
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
10596
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
106-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
10797
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
108-
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
10998
</content>
11099
<orderEntry type="jdk" jdkName="Android API 25 Platform (2)" jdkType="Android SDK" />
111100
<orderEntry type="sourceFolder" forTests="false" />
@@ -140,6 +129,7 @@
140129
<orderEntry type="library" name="com.facebook.fbui.textlayoutbuilder:staticlayout-proxy:1.0@jar" level="project" />
141130
<orderEntry type="library" name="com.android.support:appcompat-v7-25.3.1" level="project" />
142131
<orderEntry type="library" name="__local_aars__:/Users/caiyg/Desktop/github/jmessage-react-plugin/example/node_modules/jcore-react-native/android/libs/jcore-android-1.1.8.jar:unspecified@jar" level="project" />
132+
<orderEntry type="library" name="__local_aars__:/Users/caiyg/Desktop/github/jmessage-react-plugin/example/node_modules/jmessage-react-plugin/android/libs/jmessage-android_v2.5.0.jar:unspecified@jar" level="project" />
143133
<orderEntry type="library" name="org.greenrobot:eventbus:3.0.0@jar" level="project" />
144134
<orderEntry type="library" name="com.android.support:support-vector-drawable-25.3.1" level="project" />
145135
<orderEntry type="library" name="com.facebook.fbui.textlayoutbuilder:textlayoutbuilder-1.0.0" level="project" />

example/android/app/src/main/java/com/sample/application/MainApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public void onCreate() {
5050
SoLoader.init(this, /* native exopackage */ false);
5151
Log.i("MainApplication", "Init JMessageClient");
5252
JMessageClient.setDebugMode(true);
53-
// JMessageClient.init(this, true);
53+
// JMessage SDK 2.5.0 后必须在 MainApplication 中初始化
54+
JMessageClient.init(this, true);
5455
}
5556
}

example/app/routes/Home/ConversationList/ConversationListStore.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class ConversationListStore {
3535
})
3636
}
3737
} else if (item.type === "group") {
38-
item.appKey = conversation.target.ownerAppKey
38+
if (conversation.target.ownerAppKey != undefined) {
39+
item.appKey = conversation.target.ownerAppKey
40+
}
3941
item.groupId = conversation.target.id
4042
item.displayName = conversation.target.name
4143
item.avatarThumbPath = conversation.target.avatarThumbPath

example/app/routes/Home/ConversationList/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ export default class ConversationList extends React.Component {
238238
<Button
239239
onPress={() => {
240240

241-
JMessage.createGroup({ name: this.state.modalText, desc: "" }, (group) => {
241+
JMessage.createGroup({ name: this.state.modalText, desc: "" }, (groupId) => {
242242
var params = {}
243243
params.type = 'group'
244-
params.groupId = group.id
244+
params.groupId = groupId
245245
this.setState({ isShowModal: false })
246246
this.createConversation(params)
247247
}, (error) => {

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"babel-plugin-transform-decorators-legacy": "^1.3.4",
1010
"babel-preset-react-native-stage-0": "^1.0.1",
1111
"jcore-react-native": "^1.2.3",
12-
"jmessage-react-plugin": "^2.3.0",
12+
"jmessage-react-plugin": "^2.3.5",
1313
"mobx": "^3.4.1",
1414
"mobx-react": "^4.3.5",
1515
"react": "^16.0.0",

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)