juggleim-rnsdk 0.4.1 → 0.4.3
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.
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/src/main/java/com/juggleim/JuggleIMManager.java +4 -1
- package/package.json +1 -1
- package/src/index.js +34 -22
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -134,7 +134,10 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
134
134
|
logBuilder.setLogConsoleLevel(JLogLevel.JLogLevelVerbose);
|
|
135
135
|
builder.setJLogConfig(new JLogConfig(logBuilder));
|
|
136
136
|
if (enableJGPush) {
|
|
137
|
-
builder.setPushConfig(
|
|
137
|
+
builder.setPushConfig(
|
|
138
|
+
new PushConfig.Builder()
|
|
139
|
+
.setJgConfig()
|
|
140
|
+
.build());
|
|
138
141
|
}
|
|
139
142
|
JIM.getInstance().init(getCurrentActivity(), appKey, builder.build());
|
|
140
143
|
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -417,8 +417,8 @@ class JuggleIM {
|
|
|
417
417
|
if (listener.onConversationInfoAdd) {
|
|
418
418
|
const subscription = juggleIMEmitter.addListener(
|
|
419
419
|
"ConversationInfoAdded",
|
|
420
|
-
(event) => {
|
|
421
|
-
const convsList = this.buildConversationInfoList(event.conversations);
|
|
420
|
+
async (event) => {
|
|
421
|
+
const convsList = await this.buildConversationInfoList(event.conversations);
|
|
422
422
|
console.log("ConversationInfoAdded", convsList);
|
|
423
423
|
if (Platform.OS === "android" && event.key !== key) return;
|
|
424
424
|
listener.onConversationInfoAdd(convsList);
|
|
@@ -431,8 +431,8 @@ class JuggleIM {
|
|
|
431
431
|
if (listener.onConversationInfoUpdate) {
|
|
432
432
|
const subscription = juggleIMEmitter.addListener(
|
|
433
433
|
"ConversationInfoUpdated",
|
|
434
|
-
(event) => {
|
|
435
|
-
const convsList = this.buildConversationInfoList(event.conversations);
|
|
434
|
+
async (event) => {
|
|
435
|
+
const convsList = await this.buildConversationInfoList(event.conversations);
|
|
436
436
|
console.log("ConversationInfoUpdated", convsList);
|
|
437
437
|
if (Platform.OS === "android" && event.key !== key) return;
|
|
438
438
|
listener.onConversationInfoUpdate(convsList);
|
|
@@ -445,8 +445,8 @@ class JuggleIM {
|
|
|
445
445
|
if (listener.onConversationInfoDelete) {
|
|
446
446
|
const subscription = juggleIMEmitter.addListener(
|
|
447
447
|
"ConversationInfoDeleted",
|
|
448
|
-
(event) => {
|
|
449
|
-
const convsList = this.buildConversationInfoList(event.conversations);
|
|
448
|
+
async (event) => {
|
|
449
|
+
const convsList = await this.buildConversationInfoList(event.conversations);
|
|
450
450
|
console.log("ConversationInfoDeleted", convsList);
|
|
451
451
|
if (Platform.OS === "android" && event.key !== key) return;
|
|
452
452
|
listener.onConversationInfoDelete(convsList);
|
|
@@ -484,8 +484,10 @@ class JuggleIM {
|
|
|
484
484
|
option.count,
|
|
485
485
|
option.timestamp,
|
|
486
486
|
option.direction
|
|
487
|
-
).then(convs => {
|
|
488
|
-
convs
|
|
487
|
+
).then(async (convs) => {
|
|
488
|
+
const convList = convs || [];
|
|
489
|
+
// 简要描述:串行等待每个会话资料补充完成,再返回结果,避免调用方拿到半成品数据。
|
|
490
|
+
for (const conv of convList) {
|
|
489
491
|
if (conv.conversation?.conversationType === 1) {
|
|
490
492
|
const userInfo = await JMI.getUserInfo(conv.conversation?.conversationId);
|
|
491
493
|
conv.name = userInfo?.nickname;
|
|
@@ -503,8 +505,8 @@ class JuggleIM {
|
|
|
503
505
|
conv.lastMessage.senderUserAvatar = userInfo?.avatar;
|
|
504
506
|
conv.lastMessage.senderUserExtra = userInfo?.extra;
|
|
505
507
|
}
|
|
506
|
-
}
|
|
507
|
-
resolve(
|
|
508
|
+
}
|
|
509
|
+
resolve(convList);
|
|
508
510
|
}).catch(err => {
|
|
509
511
|
console.error(err);
|
|
510
512
|
reject(err);
|
|
@@ -512,8 +514,15 @@ class JuggleIM {
|
|
|
512
514
|
});
|
|
513
515
|
}
|
|
514
516
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
+
/**
|
|
518
|
+
* 构建会话信息列表(补齐会话名、头像、扩展信息及最后一条消息发送者信息)
|
|
519
|
+
* @param {Array} convs - 原始会话列表
|
|
520
|
+
* @returns {Promise<Array>} 补齐后的会话列表
|
|
521
|
+
*/
|
|
522
|
+
static async buildConversationInfoList(convs) {
|
|
523
|
+
const convList = convs || [];
|
|
524
|
+
// 简要描述:会话监听场景下,也要等待用户/群组信息补齐后再通知上层。
|
|
525
|
+
for (const conv of convList) {
|
|
517
526
|
if (conv.conversation?.conversationType === 1) {
|
|
518
527
|
const userInfo = await JMI.getUserInfo(conv.conversation?.conversationId);
|
|
519
528
|
conv.name = userInfo?.nickname;
|
|
@@ -531,8 +540,8 @@ class JuggleIM {
|
|
|
531
540
|
conv.lastMessage.senderUserAvatar = userInfo?.avatar;
|
|
532
541
|
conv.lastMessage.senderUserExtra = userInfo?.extra;
|
|
533
542
|
}
|
|
534
|
-
}
|
|
535
|
-
return
|
|
543
|
+
}
|
|
544
|
+
return convList;
|
|
536
545
|
}
|
|
537
546
|
|
|
538
547
|
static async buildMessageInfo(message) {
|
|
@@ -737,8 +746,10 @@ class JuggleIM {
|
|
|
737
746
|
*/
|
|
738
747
|
static getTopConversationInfoList(count = 20, timestamp = 0, direction = 0) {
|
|
739
748
|
return new Promise((resolve, reject) => {
|
|
740
|
-
JMI.getTopConversationInfoList(count, timestamp, direction).then(convs => {
|
|
741
|
-
convs
|
|
749
|
+
JMI.getTopConversationInfoList(count, timestamp, direction).then(async (convs) => {
|
|
750
|
+
const convList = convs || [];
|
|
751
|
+
// 简要描述:先补齐置顶会话展示字段,再统一返回,避免 UI 出现名称/头像延迟闪动。
|
|
752
|
+
for (const conv of convList) {
|
|
742
753
|
if (conv.conversation?.conversationType === 1) {
|
|
743
754
|
const userInfo = await JMI.getUserInfo(conv.conversation?.userId);
|
|
744
755
|
conv.name = userInfo?.nickname;
|
|
@@ -756,8 +767,8 @@ class JuggleIM {
|
|
|
756
767
|
conv.lastMessage.senderUserAvatar = userInfo?.avatar;
|
|
757
768
|
conv.lastMessage.senderUserExtra = userInfo?.extra;
|
|
758
769
|
}
|
|
759
|
-
}
|
|
760
|
-
resolve(
|
|
770
|
+
}
|
|
771
|
+
resolve(convList);
|
|
761
772
|
}).catch(err => {
|
|
762
773
|
console.error(err);
|
|
763
774
|
reject(err);
|
|
@@ -1219,14 +1230,15 @@ class JuggleIM {
|
|
|
1219
1230
|
*/
|
|
1220
1231
|
static getMessageList(conversation, direction, options) {
|
|
1221
1232
|
return new Promise((resolve, reject) => {
|
|
1222
|
-
JMI.getMessages(conversation, direction, options).then(res => {
|
|
1233
|
+
JMI.getMessages(conversation, direction, options).then(async (res) => {
|
|
1223
1234
|
const msgs = res?.messages;
|
|
1224
|
-
|
|
1235
|
+
// 简要描述:等待消息发送者资料补齐后再返回,避免消息列表显示占位昵称/头像。
|
|
1236
|
+
for (const msg of (msgs || [])) {
|
|
1225
1237
|
const userInfo = await JMI.getUserInfo(msg.senderUserId);
|
|
1226
1238
|
msg.senderUserName = userInfo?.nickname;
|
|
1227
1239
|
msg.senderUserAvatar = userInfo?.avatar;
|
|
1228
1240
|
msg.senderUserExtra = userInfo?.extra;
|
|
1229
|
-
}
|
|
1241
|
+
}
|
|
1230
1242
|
resolve(res);
|
|
1231
1243
|
}).catch(err => {
|
|
1232
1244
|
console.error(err);
|
|
@@ -1573,4 +1585,4 @@ export {
|
|
|
1573
1585
|
JuggleIMMoment,
|
|
1574
1586
|
JuggleIM
|
|
1575
1587
|
};
|
|
1576
|
-
export default JuggleIM;
|
|
1588
|
+
export default JuggleIM;
|