Skip to content

Commit 209b9a0

Browse files
committed
add conversation extras field
1 parent d9af973 commit 209b9a0

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

android/src/main/java/com/jiguang/jmessageflutter/JmessageFlutterPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,8 @@ private void setConversationExtras(MethodCall call, Result result) {
678678
return;
679679
}
680680

681-
if (params.has("extra")) {
682-
extra = params.getJSONObject("extra");
681+
if (params.has("extras")) {
682+
extra = params.getJSONObject("extras");
683683
}
684684
} catch (JSONException e) {
685685
e.printStackTrace();

android/src/main/java/com/jiguang/jmessageflutter/JsonUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ static HashMap toJson(Conversation conversation) {
430430
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
431431
extrasMap.put(entry.getKey(), entry.getValue().toString());
432432
}
433-
json.put("extra", extrasMap);
433+
json.put("extras", extrasMap);
434434
} else {
435-
json.put("extra", new HashMap());
435+
json.put("extras", new HashMap());
436436
}
437437

438438
Log.d("flutter plugin","native the conversation:" + json.toString());

ios/Classes/JmessageFlutterPlugin.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ - (void)setConversationExtras:(FlutterMethodCall*)call result:(FlutterResult)res
822822
}
823823

824824
[self getConversationWithDictionary:param callback:^(JMSGConversation *conversation, NSError *error) {
825-
if (error) {
825+
826826
if (error) {
827827
result([error flutterError]);
828828
return ;
@@ -834,7 +834,7 @@ - (void)setConversationExtras:(FlutterMethodCall*)call result:(FlutterResult)res
834834
}
835835
result([conversation conversationToDictionary]);
836836
return;
837-
}
837+
838838
}];
839839
}
840840

lib/jmessage_flutter.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,11 +1988,13 @@ class JMConversationInfo {
19881988
int unreadCount; // 未读消息数
19891989
dynamic target; // JMUserInfo or JMGroupInfo or JMChatRoom
19901990
dynamic latestMessage; // 最近的一条消息对象。如果不存在消息,则 conversation 对象中没有该属性。
1991-
1991+
Map<dynamic, dynamic> extras;
1992+
19921993
JMConversationInfo.fromJson(Map<dynamic, dynamic> json)
19931994
: conversationType = getEnumFromString(JMConversationType.values, json['conversationType']),
19941995
title = json['title'],
1995-
unreadCount = json['unreadCount'] {
1996+
unreadCount = json['unreadCount'],
1997+
extras = json['extras'] {
19961998
switch (conversationType) {
19971999
case JMConversationType.single:
19982000
target = JMUserInfo.fromJson(json['target']);
@@ -2015,6 +2017,7 @@ class JMConversationInfo {
20152017

20162018
// extras use Map<String, String>
20172019
Future<void> setExtras(Map<dynamic, dynamic> extras) async {
2020+
this.extras = extras;
20182021
await JmessageFlutter().setConversationExtras(
20192022
type: target.targetType,
20202023
extras: extras,

0 commit comments

Comments
 (0)