mirror of
https://github.com/WuKongIM/WuKongIMFlutterSDK
synced 2025-05-29 15:12:20 +00:00
fix: Modifying non JSON serialization errors in extended fields
This commit is contained in:
parent
c9f359906e
commit
5f686c4f90
@ -79,4 +79,6 @@
|
||||
### 1.3.9
|
||||
* fix: Update RecvAckPacket header encode method
|
||||
### 1.4.0
|
||||
* fix: Modifying the issue of a large number of offline messages getting stuck during synchronization
|
||||
* fix: Modifying the issue of a large number of offline messages getting stuck during synchronization
|
||||
### 1.4.1
|
||||
* fix: Modifying non JSON serialization errors in extended fields
|
@ -9,7 +9,7 @@
|
||||
#### 安装
|
||||
```
|
||||
dependencies:
|
||||
wukongimfluttersdk: ^1.4.0
|
||||
wukongimfluttersdk: ^1.4.1
|
||||
```
|
||||
#### 引入
|
||||
```dart
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:wukongimfluttersdk/entity/msg.dart';
|
||||
import 'package:wukongimfluttersdk/type/const.dart';
|
||||
import 'package:wukongimfluttersdk/wkim.dart';
|
||||
|
||||
import 'const.dart';
|
||||
|
||||
|
@ -46,11 +46,7 @@ class WKDBConst {
|
||||
msg.topicID = readString(data, 'topic_id');
|
||||
// 扩展表数据
|
||||
msg.wkMsgExtra = serializeMsgExtra(data);
|
||||
|
||||
String extra = readString(data, 'extra');
|
||||
if (extra != '') {
|
||||
msg.localExtraMap = jsonEncode(extra);
|
||||
}
|
||||
msg.localExtraMap = readDynamic(data, 'extra');
|
||||
if (msg.content != '') {
|
||||
dynamic contentJson = jsonDecode(msg.content);
|
||||
msg.messageContent = WKIM.shared.messageManager
|
||||
@ -109,10 +105,7 @@ class WKDBConst {
|
||||
msg.lastMsgSeq = readInt(data, 'last_msg_seq');
|
||||
msg.parentChannelID = readString(data, 'parent_channel_id');
|
||||
msg.parentChannelType = readInt(data, 'parent_channel_type');
|
||||
String extra = readString(data, 'extra');
|
||||
if (extra != '') {
|
||||
msg.localExtraMap = jsonDecode(extra);
|
||||
}
|
||||
msg.localExtraMap = readDynamic(data, 'extra');
|
||||
msg.msgExtra = serializeConversationExtra(data);
|
||||
return msg;
|
||||
}
|
||||
@ -167,14 +160,8 @@ class WKDBConst {
|
||||
}
|
||||
channel.createdAt = readString(data, 'created_at');
|
||||
channel.updatedAt = readString(data, 'updated_at');
|
||||
String remoteExtra = readString(data, 'remote_extra');
|
||||
if (remoteExtra != '') {
|
||||
channel.remoteExtraMap = jsonDecode(remoteExtra);
|
||||
}
|
||||
String localExtra = readString(data, 'extra');
|
||||
if (remoteExtra != '') {
|
||||
channel.localExtra = jsonDecode(localExtra);
|
||||
}
|
||||
channel.remoteExtraMap = readDynamic(data, 'remote_extra');
|
||||
channel.localExtra = readDynamic(data, 'extra');
|
||||
return channel;
|
||||
}
|
||||
|
||||
@ -210,11 +197,7 @@ class WKDBConst {
|
||||
} else {
|
||||
member.memberAvatarCacheKey = readString(data, 'member_avatar_cache_key');
|
||||
}
|
||||
String extra = readString(data, 'extra');
|
||||
if (extra != '') {
|
||||
member.extraMap = jsonDecode(extra);
|
||||
}
|
||||
|
||||
member.extraMap = readDynamic(data, 'extra');
|
||||
return member;
|
||||
}
|
||||
|
||||
@ -230,12 +213,9 @@ class WKDBConst {
|
||||
reminder.text = readString(data, 'text');
|
||||
reminder.version = readInt(data, 'version');
|
||||
reminder.done = readInt(data, 'done');
|
||||
String data1 = readString(data, 'data');
|
||||
reminder.needUpload = readInt(data, 'need_upload');
|
||||
reminder.publisher = readString(data, 'publisher');
|
||||
if (data1 != '') {
|
||||
reminder.data = jsonDecode(data1);
|
||||
}
|
||||
reminder.data = readDynamic(data, 'data');
|
||||
return reminder;
|
||||
}
|
||||
|
||||
@ -255,6 +235,23 @@ class WKDBConst {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
static dynamic readDynamic(dynamic data, String key) {
|
||||
String jsonStr = readString(data, key);
|
||||
if (jsonStr != '' && isJsonString(jsonStr)) {
|
||||
return jsonDecode(jsonStr);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
static bool isJsonString(String str) {
|
||||
try {
|
||||
final parsed = json.decode(str);
|
||||
return parsed is Map || parsed is List;
|
||||
} on FormatException {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static String getPlaceholders(int count) {
|
||||
StringBuffer placeholders = StringBuffer();
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -378,7 +378,11 @@ class MessageDB {
|
||||
oldestMsgSeq != 0 &&
|
||||
oldestMsgSeq - maxMessageSeq > 1) {
|
||||
isSyncMsg = true;
|
||||
startMsgSeq = oldestMsgSeq;
|
||||
if (contain) {
|
||||
startMsgSeq = oldestMsgSeq;
|
||||
} else {
|
||||
startMsgSeq = oldestMsgSeq - 1;
|
||||
}
|
||||
endMsgSeq = maxMessageSeq;
|
||||
}
|
||||
} else {
|
||||
@ -387,7 +391,11 @@ class MessageDB {
|
||||
oldestMsgSeq != 0 &&
|
||||
minMessageSeq - oldestMsgSeq > 1) {
|
||||
isSyncMsg = true;
|
||||
startMsgSeq = oldestMsgSeq;
|
||||
if (contain) {
|
||||
startMsgSeq = oldestMsgSeq;
|
||||
} else {
|
||||
startMsgSeq = oldestMsgSeq + 1;
|
||||
}
|
||||
endMsgSeq = minMessageSeq;
|
||||
}
|
||||
}
|
||||
@ -413,13 +421,20 @@ class MessageDB {
|
||||
}
|
||||
if (pullMode == 0) {
|
||||
// 下拉
|
||||
startMsgSeq = max;
|
||||
endMsgSeq = min;
|
||||
if (max > startMsgSeq) {
|
||||
startMsgSeq = max;
|
||||
}
|
||||
if (endMsgSeq == 0 || min < endMsgSeq) {
|
||||
endMsgSeq = min;
|
||||
}
|
||||
} else {
|
||||
startMsgSeq = min;
|
||||
endMsgSeq = max;
|
||||
if (startMsgSeq == 0 || min < startMsgSeq) {
|
||||
startMsgSeq = min;
|
||||
}
|
||||
if (max > endMsgSeq) {
|
||||
endMsgSeq = max;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -754,6 +769,14 @@ class MessageDB {
|
||||
return wkMsg;
|
||||
}
|
||||
|
||||
Future<int> deleteWithMessageIDs(List<String> msgIds) async {
|
||||
var map = <String, Object>{};
|
||||
map['is_deleted'] = 1;
|
||||
return await WKDBHelper.shared.getDB().update(WKDBConst.tableMessage, map,
|
||||
where: "message_id in (${WKDBConst.getPlaceholders(msgIds.length)})",
|
||||
whereArgs: msgIds);
|
||||
}
|
||||
|
||||
Future<int> deleteWithChannel(String channelId, int channelType) async {
|
||||
var map = <String, Object>{};
|
||||
map['is_deleted'] = 1;
|
||||
|
@ -172,8 +172,12 @@ class WKMessageManager {
|
||||
saveRemoteExtraMsg(List<WKMsgExtra> list) async {
|
||||
MessageDB.shared.insertMsgExtras(list);
|
||||
List<String> msgIds = [];
|
||||
List<String> deletedMsgIds = [];
|
||||
for (var extra in list) {
|
||||
msgIds.add(extra.messageID);
|
||||
if (extra.isMutualDeleted == 1) {
|
||||
deletedMsgIds.add(extra.messageID);
|
||||
}
|
||||
}
|
||||
var msgList = await MessageDB.shared.queryWithMessageIds(msgIds);
|
||||
for (var msg in msgList) {
|
||||
@ -199,6 +203,9 @@ class WKMessageManager {
|
||||
}
|
||||
setRefreshMsg(msg);
|
||||
}
|
||||
if (deletedMsgIds.isNotEmpty) {
|
||||
MessageDB.shared.deleteWithMessageIDs(deletedMsgIds);
|
||||
}
|
||||
}
|
||||
|
||||
void setSyncChannelMsgListener(
|
||||
|
@ -15,7 +15,7 @@ description: wukong IM flutter sdk
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.4.0
|
||||
version: 1.4.1
|
||||
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
||||
|
||||
environment:
|
||||
|
Loading…
x
Reference in New Issue
Block a user