mirror of
https://github.com/WuKongIM/WuKongIMFlutterSDK
synced 2025-05-29 15:12:20 +00:00
add some methods
This commit is contained in:
parent
345e15b3d9
commit
f3b36c067e
@ -23,4 +23,6 @@
|
|||||||
### 1.1.1
|
### 1.1.1
|
||||||
* Update online cmd messages
|
* Update online cmd messages
|
||||||
### 1.1.2
|
### 1.1.2
|
||||||
* Optimize connections
|
* Optimize connections
|
||||||
|
### 1.1.3
|
||||||
|
* Add some methods
|
@ -9,7 +9,7 @@
|
|||||||
#### 安装
|
#### 安装
|
||||||
```
|
```
|
||||||
dependencies:
|
dependencies:
|
||||||
wukongimfluttersdk: ^1.1.2
|
wukongimfluttersdk: ^1.1.3
|
||||||
```
|
```
|
||||||
#### 引入
|
#### 引入
|
||||||
```dart
|
```dart
|
||||||
|
@ -40,6 +40,7 @@ class HttpUtils {
|
|||||||
lastSsgSeqs, // 客户端所有频道会话的最后一条消息序列号拼接出来的同步串 格式: channelID:channelType:last_msg_seq|channelID:channelType:last_msg_seq (此字段非必填,如果不填就获取全量数据,填写了获取增量数据,看你自己的需求。)
|
lastSsgSeqs, // 客户端所有频道会话的最后一条消息序列号拼接出来的同步串 格式: channelID:channelType:last_msg_seq|channelID:channelType:last_msg_seq (此字段非必填,如果不填就获取全量数据,填写了获取增量数据,看你自己的需求。)
|
||||||
"msg_count": 10 // 每个会话获取最大的消息数量,一般为app点进去第一屏的数据
|
"msg_count": 10 // 每个会话获取最大的消息数量,一般为app点进去第一屏的数据
|
||||||
});
|
});
|
||||||
|
print(response.data);
|
||||||
WKSyncConversation conversation = WKSyncConversation();
|
WKSyncConversation conversation = WKSyncConversation();
|
||||||
conversation.conversations = [];
|
conversation.conversations = [];
|
||||||
if (response.statusCode == HttpStatus.ok) {
|
if (response.statusCode == HttpStatus.ok) {
|
||||||
|
@ -499,7 +499,7 @@ packages:
|
|||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "1.1.2"
|
version: "1.1.3"
|
||||||
x25519:
|
x25519:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -141,20 +141,18 @@ class ConversationDB {
|
|||||||
List<Map<String, dynamic>> updateList = [];
|
List<Map<String, dynamic>> updateList = [];
|
||||||
|
|
||||||
for (WKConversationMsg msg in list) {
|
for (WKConversationMsg msg in list) {
|
||||||
|
bool isAdd = true;
|
||||||
if (existList.isNotEmpty) {
|
if (existList.isNotEmpty) {
|
||||||
for (var i = 0; i < existList.length; i++) {
|
for (var i = 0; i < existList.length; i++) {
|
||||||
bool isAdd = true;
|
|
||||||
if (existList[i].channelID == msg.channelID &&
|
if (existList[i].channelID == msg.channelID &&
|
||||||
existList[i].channelType == msg.channelType) {
|
existList[i].channelType == msg.channelType) {
|
||||||
updateList.add(getMap(msg, true));
|
updateList.add(getMap(msg, true));
|
||||||
isAdd = false;
|
isAdd = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isAdd) {
|
|
||||||
insertList.add(getMap(msg, true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
if (isAdd) {
|
||||||
insertList.add(getMap(msg, true));
|
insertList.add(getMap(msg, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,6 +174,31 @@ class ConversationDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll() {
|
||||||
|
WKDBHelper.shared.getDB().delete(WKDBConst.tableConversation);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> queryExtraMaxVersion() async {
|
||||||
|
int maxVersion = 0;
|
||||||
|
String sql =
|
||||||
|
"select max(version) version from ${WKDBConst.tableConversationExtra}";
|
||||||
|
|
||||||
|
List<Map<String, Object?>> list =
|
||||||
|
await WKDBHelper.shared.getDB().rawQuery(sql);
|
||||||
|
if (list.isNotEmpty) {
|
||||||
|
dynamic data = list[0];
|
||||||
|
maxVersion = WKDBConst.readInt(data, 'version');
|
||||||
|
}
|
||||||
|
return maxVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> updateWithField(
|
||||||
|
dynamic map, String channelID, int channelType) async {
|
||||||
|
return await WKDBHelper.shared.getDB().update(
|
||||||
|
WKDBConst.tableConversation, map,
|
||||||
|
where: "channel_id=$channelID and channel_type=$channelType");
|
||||||
|
}
|
||||||
|
|
||||||
WKUIConversationMsg getUIMsg(WKConversationMsg conversationMsg) {
|
WKUIConversationMsg getUIMsg(WKConversationMsg conversationMsg) {
|
||||||
WKUIConversationMsg msg = WKUIConversationMsg();
|
WKUIConversationMsg msg = WKUIConversationMsg();
|
||||||
msg.lastMsgSeq = conversationMsg.lastMsgSeq;
|
msg.lastMsgSeq = conversationMsg.lastMsgSeq;
|
||||||
|
@ -11,10 +11,10 @@ import '../entity/channel_member.dart';
|
|||||||
import 'channel_member.dart';
|
import 'channel_member.dart';
|
||||||
import 'wk_db_helper.dart';
|
import 'wk_db_helper.dart';
|
||||||
|
|
||||||
class MessaggeDB {
|
class MessageDB {
|
||||||
MessaggeDB._privateConstructor();
|
MessageDB._privateConstructor();
|
||||||
static final MessaggeDB _instance = MessaggeDB._privateConstructor();
|
static final MessageDB _instance = MessageDB._privateConstructor();
|
||||||
static MessaggeDB get shared => _instance;
|
static MessageDB get shared => _instance;
|
||||||
final String extraCols =
|
final String extraCols =
|
||||||
"IFNULL(${WKDBConst.tableMessageExtra}.readed,0) as readed,IFNULL(${WKDBConst.tableMessageExtra}.readed_count,0) as readed_count,IFNULL(${WKDBConst.tableMessageExtra}.unread_count,0) as unread_count,IFNULL(${WKDBConst.tableMessageExtra}.revoke,0) as revoke,IFNULL(${WKDBConst.tableMessageExtra}.revoker,'') as revoker,IFNULL(${WKDBConst.tableMessageExtra}.extra_version,0) as extra_version,IFNULL(${WKDBConst.tableMessageExtra}.is_mutual_deleted,0) as is_mutual_deleted,IFNULL(${WKDBConst.tableMessageExtra}.need_upload,0) as need_upload,IFNULL(${WKDBConst.tableMessageExtra}.content_edit,'') as content_edit,IFNULL(${WKDBConst.tableMessageExtra}.edited_at,0) as edited_at";
|
"IFNULL(${WKDBConst.tableMessageExtra}.readed,0) as readed,IFNULL(${WKDBConst.tableMessageExtra}.readed_count,0) as readed_count,IFNULL(${WKDBConst.tableMessageExtra}.unread_count,0) as unread_count,IFNULL(${WKDBConst.tableMessageExtra}.revoke,0) as revoke,IFNULL(${WKDBConst.tableMessageExtra}.revoker,'') as revoker,IFNULL(${WKDBConst.tableMessageExtra}.extra_version,0) as extra_version,IFNULL(${WKDBConst.tableMessageExtra}.is_mutual_deleted,0) as is_mutual_deleted,IFNULL(${WKDBConst.tableMessageExtra}.need_upload,0) as need_upload,IFNULL(${WKDBConst.tableMessageExtra}.content_edit,'') as content_edit,IFNULL(${WKDBConst.tableMessageExtra}.edited_at,0) as edited_at";
|
||||||
final String messageCols =
|
final String messageCols =
|
||||||
@ -714,6 +714,25 @@ class MessaggeDB {
|
|||||||
.update(WKDBConst.tableMessage, map, where: 'status=0');
|
.update(WKDBConst.tableMessage, map, where: 'status=0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<WKMsg?> queryMaxOrderSeqMsgWithChannel(
|
||||||
|
String channelID, int channelType) async {
|
||||||
|
WKMsg? wkMsg;
|
||||||
|
String sql =
|
||||||
|
"select * from ${WKDBConst.tableMessage} where channel_id='$channelID' and channel_type=$channelType and is_deleted=0 and type<>0 and type<>99 order by order_seq desc limit 1";
|
||||||
|
List<Map<String, Object?>> list =
|
||||||
|
await WKDBHelper.shared.getDB().rawQuery(sql);
|
||||||
|
if (list.isNotEmpty) {
|
||||||
|
dynamic data = list[0];
|
||||||
|
if (data != null) {
|
||||||
|
wkMsg = WKDBConst.serializeWKMsg(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wkMsg != null) {
|
||||||
|
wkMsg.reactionList = await queryReactions(wkMsg.messageID);
|
||||||
|
}
|
||||||
|
return wkMsg;
|
||||||
|
}
|
||||||
|
|
||||||
dynamic getMap(WKMsg msg) {
|
dynamic getMap(WKMsg msg) {
|
||||||
var map = <String, Object>{};
|
var map = <String, Object>{};
|
||||||
map['message_id'] = msg.messageID;
|
map['message_id'] = msg.messageID;
|
||||||
|
@ -55,6 +55,43 @@ class WKConversationManager {
|
|||||||
return uiMsg;
|
return uiMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> getExtraMaxVersion() async {
|
||||||
|
return ConversationDB.shared.queryExtraMaxVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<WKUIConversationMsg?> getWithChannel(
|
||||||
|
String channelID, int channelType) async {
|
||||||
|
var msg = await ConversationDB.shared
|
||||||
|
.queryMsgByMsgChannelId(channelID, channelType);
|
||||||
|
if (msg != null) {
|
||||||
|
return ConversationDB.shared.getUIMsg(msg);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAll() {
|
||||||
|
ConversationDB.shared.clearAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRedDot(String channelID, int channelType, int redDot) async {
|
||||||
|
var map = <String, Object>{};
|
||||||
|
map['unread_count'] = redDot;
|
||||||
|
var result = await ConversationDB.shared
|
||||||
|
.updateWithField(map, channelID, channelType);
|
||||||
|
if (result > 0) {
|
||||||
|
_refreshMsg(channelID, channelType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_refreshMsg(String channelID, int channelType) async {
|
||||||
|
var msg = await ConversationDB.shared
|
||||||
|
.queryMsgByMsgChannelId(channelID, channelType);
|
||||||
|
if (msg != null) {
|
||||||
|
var uiMsg = ConversationDB.shared.getUIMsg(msg);
|
||||||
|
setRefreshMsg(uiMsg, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addOnDeleteMsgListener(String key, Function(String, int) back) {
|
addOnDeleteMsgListener(String key, Function(String, int) back) {
|
||||||
_deleteMsgMap ??= HashMap();
|
_deleteMsgMap ??= HashMap();
|
||||||
_deleteMsgMap![key] = back;
|
_deleteMsgMap![key] = back;
|
||||||
@ -174,17 +211,17 @@ class WKConversationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msgExtraList.isNotEmpty) {
|
if (msgExtraList.isNotEmpty) {
|
||||||
MessaggeDB.shared.insertOrUpdateMsgExtras(msgExtraList);
|
MessageDB.shared.insertOrUpdateMsgExtras(msgExtraList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgList.isNotEmpty) {
|
if (msgList.isNotEmpty) {
|
||||||
MessaggeDB.shared.insertMsgList(msgList);
|
MessageDB.shared.insertMsgList(msgList);
|
||||||
}
|
}
|
||||||
if (conversationMsgList.isNotEmpty) {
|
if (conversationMsgList.isNotEmpty) {
|
||||||
ConversationDB.shared.insertMsgList(conversationMsgList);
|
ConversationDB.shared.insertMsgList(conversationMsgList);
|
||||||
}
|
}
|
||||||
if (msgReactionList.isNotEmpty) {
|
if (msgReactionList.isNotEmpty) {
|
||||||
MessaggeDB.shared.insertOrUpdateReactionList(msgReactionList);
|
MessageDB.shared.insertOrUpdateReactionList(msgReactionList);
|
||||||
}
|
}
|
||||||
if (msgList.isNotEmpty && msgList.length < 20) {
|
if (msgList.isNotEmpty && msgList.length < 20) {
|
||||||
msgList.sort((a, b) => a.messageSeq.compareTo(b.messageSeq));
|
msgList.sort((a, b) => a.messageSeq.compareTo(b.messageSeq));
|
||||||
|
@ -4,6 +4,7 @@ import 'dart:convert';
|
|||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
import 'package:wukongimfluttersdk/common/logs.dart';
|
import 'package:wukongimfluttersdk/common/logs.dart';
|
||||||
import 'package:wukongimfluttersdk/db/const.dart';
|
import 'package:wukongimfluttersdk/db/const.dart';
|
||||||
|
import 'package:wukongimfluttersdk/db/conversation.dart';
|
||||||
import 'package:wukongimfluttersdk/db/message.dart';
|
import 'package:wukongimfluttersdk/db/message.dart';
|
||||||
import 'package:wukongimfluttersdk/entity/msg.dart';
|
import 'package:wukongimfluttersdk/entity/msg.dart';
|
||||||
import 'package:wukongimfluttersdk/model/wk_media_message_content.dart';
|
import 'package:wukongimfluttersdk/model/wk_media_message_content.dart';
|
||||||
@ -29,6 +30,8 @@ class WKMessageManager {
|
|||||||
Function(WKMsg liMMsg)? _msgInsertedBack;
|
Function(WKMsg liMMsg)? _msgInsertedBack;
|
||||||
HashMap<String, Function(List<WKMsg>)>? _newMsgBack;
|
HashMap<String, Function(List<WKMsg>)>? _newMsgBack;
|
||||||
HashMap<String, Function(WKMsg)>? _refreshMsgBack;
|
HashMap<String, Function(WKMsg)>? _refreshMsgBack;
|
||||||
|
HashMap<String, Function(String)>? _deleteMsgBack;
|
||||||
|
|
||||||
Function(
|
Function(
|
||||||
String channelID,
|
String channelID,
|
||||||
int channelType,
|
int channelType,
|
||||||
@ -86,11 +89,11 @@ class WKMessageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<WKMsg?> getWithClientMsgNo(String clientMsgNo) {
|
Future<WKMsg?> getWithClientMsgNo(String clientMsgNo) {
|
||||||
return MessaggeDB.shared.queryWithClientMsgNo(clientMsgNo);
|
return MessageDB.shared.queryWithClientMsgNo(clientMsgNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> saveMsg(WKMsg msg) async {
|
Future<int> saveMsg(WKMsg msg) async {
|
||||||
return await MessaggeDB.shared.insert(msg);
|
return await MessageDB.shared.insert(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
String generateClientMsgNo() {
|
String generateClientMsgNo() {
|
||||||
@ -101,7 +104,7 @@ class WKMessageManager {
|
|||||||
int messageSeq, String channelID, int channelType) async {
|
int messageSeq, String channelID, int channelType) async {
|
||||||
if (messageSeq == 0) {
|
if (messageSeq == 0) {
|
||||||
int tempOrderSeq =
|
int tempOrderSeq =
|
||||||
await MessaggeDB.shared.queryMaxOrderSeq(channelID, channelType);
|
await MessageDB.shared.queryMaxOrderSeq(channelID, channelType);
|
||||||
return tempOrderSeq + 1;
|
return tempOrderSeq + 1;
|
||||||
}
|
}
|
||||||
return messageSeq * wkOrderSeqFactor;
|
return messageSeq * wkOrderSeqFactor;
|
||||||
@ -111,23 +114,22 @@ class WKMessageManager {
|
|||||||
dynamic json = <String, Object>{};
|
dynamic json = <String, Object>{};
|
||||||
json['viewed'] = 1;
|
json['viewed'] = 1;
|
||||||
json['viewed_at'] = viewedAt;
|
json['viewed_at'] = viewedAt;
|
||||||
return MessaggeDB.shared
|
return MessageDB.shared.updateMsgWithFieldAndClientMsgNo(json, clientMsgNO);
|
||||||
.updateMsgWithFieldAndClientMsgNo(json, clientMsgNO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getMaxExtraVersionWithChannel(
|
Future<int> getMaxExtraVersionWithChannel(
|
||||||
String channelID, int channelType) async {
|
String channelID, int channelType) async {
|
||||||
return MessaggeDB.shared
|
return MessageDB.shared
|
||||||
.queryMaxExtraVersionWithChannel(channelID, channelType);
|
.queryMaxExtraVersionWithChannel(channelID, channelType);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveRemoteExtraMsg(List<WKMsgExtra> list) async {
|
saveRemoteExtraMsg(List<WKMsgExtra> list) async {
|
||||||
MessaggeDB.shared.insertOrUpdateMsgExtras(list);
|
MessageDB.shared.insertOrUpdateMsgExtras(list);
|
||||||
List<String> msgIds = [];
|
List<String> msgIds = [];
|
||||||
for (var extra in list) {
|
for (var extra in list) {
|
||||||
msgIds.add(extra.messageID);
|
msgIds.add(extra.messageID);
|
||||||
}
|
}
|
||||||
var msgList = await MessaggeDB.shared.queryWithMessageIds(msgIds);
|
var msgList = await MessageDB.shared.queryWithMessageIds(msgIds);
|
||||||
for (var msg in msgList) {
|
for (var msg in msgList) {
|
||||||
for (var extra in list) {
|
for (var extra in list) {
|
||||||
msg.wkMsgExtra ??= WKMsgExtra();
|
msg.wkMsgExtra ??= WKMsgExtra();
|
||||||
@ -187,10 +189,10 @@ class WKMessageManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msgExtraList.isNotEmpty) {
|
if (msgExtraList.isNotEmpty) {
|
||||||
MessaggeDB.shared.insertOrUpdateMsgExtras(msgExtraList);
|
MessageDB.shared.insertOrUpdateMsgExtras(msgExtraList);
|
||||||
}
|
}
|
||||||
if (msgList.isNotEmpty) {
|
if (msgList.isNotEmpty) {
|
||||||
MessaggeDB.shared.insertMsgList(msgList);
|
MessageDB.shared.insertMsgList(msgList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +252,7 @@ class WKMessageManager {
|
|||||||
contain = true;
|
contain = true;
|
||||||
pullMode = 0;
|
pullMode = 0;
|
||||||
} else {
|
} else {
|
||||||
int minOrderSeq = await MessaggeDB.shared
|
int minOrderSeq = await MessageDB.shared
|
||||||
.getOrderSeq(channelId, channelType, aroundMsgOrderSeq, 3);
|
.getOrderSeq(channelId, channelType, aroundMsgOrderSeq, 3);
|
||||||
if (minOrderSeq == 0) {
|
if (minOrderSeq == 0) {
|
||||||
oldestOrderSeq = aroundMsgOrderSeq;
|
oldestOrderSeq = aroundMsgOrderSeq;
|
||||||
@ -265,7 +267,7 @@ class WKMessageManager {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// todo 这里只会查询3条数据 oldestOrderSeq = minOrderSeq
|
// todo 这里只会查询3条数据 oldestOrderSeq = minOrderSeq
|
||||||
int startOrderSeq = await MessaggeDB.shared
|
int startOrderSeq = await MessageDB.shared
|
||||||
.getOrderSeq(channelId, channelType, aroundMsgOrderSeq, limit);
|
.getOrderSeq(channelId, channelType, aroundMsgOrderSeq, limit);
|
||||||
if (startOrderSeq == 0) {
|
if (startOrderSeq == 0) {
|
||||||
oldestOrderSeq = aroundMsgOrderSeq;
|
oldestOrderSeq = aroundMsgOrderSeq;
|
||||||
@ -278,7 +280,7 @@ class WKMessageManager {
|
|||||||
contain = true;
|
contain = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessaggeDB.shared.getOrSyncHistoryMessages(
|
MessageDB.shared.getOrSyncHistoryMessages(
|
||||||
channelId,
|
channelId,
|
||||||
channelType,
|
channelType,
|
||||||
oldestOrderSeq,
|
oldestOrderSeq,
|
||||||
@ -297,7 +299,7 @@ class WKMessageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getMaxMessageSeq(String channelID, int channelType) {
|
Future<int> getMaxMessageSeq(String channelID, int channelType) {
|
||||||
return MessaggeDB.shared.getMaxMessageSeq(channelID, channelType);
|
return MessageDB.shared.getMaxMessageSeq(channelID, channelType);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushNewMsg(List<WKMsg> list) {
|
pushNewMsg(List<WKMsg> list) {
|
||||||
@ -321,6 +323,27 @@ class WKMessageManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addOnDeleteMsgListener(String key, Function(String) back) {
|
||||||
|
_deleteMsgBack ??= HashMap();
|
||||||
|
if (key != '') {
|
||||||
|
_deleteMsgBack![key] = back;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
removeDeleteMsgListener(String key) {
|
||||||
|
if (_deleteMsgBack != null) {
|
||||||
|
_deleteMsgBack!.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_setDeleteMsg(String clientMsgNo) {
|
||||||
|
if (_deleteMsgBack != null) {
|
||||||
|
_deleteMsgBack!.forEach((key, back) {
|
||||||
|
back(clientMsgNo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addOnRefreshMsgListener(String key, Function(WKMsg) back) {
|
addOnRefreshMsgListener(String key, Function(WKMsg) back) {
|
||||||
_refreshMsgBack ??= HashMap();
|
_refreshMsgBack ??= HashMap();
|
||||||
if (key != '') {
|
if (key != '') {
|
||||||
@ -393,7 +416,7 @@ class WKMessageManager {
|
|||||||
wkMsg.channelType = channel.channelType;
|
wkMsg.channelType = channel.channelType;
|
||||||
wkMsg.fromUID = WKIM.shared.options.uid!;
|
wkMsg.fromUID = WKIM.shared.options.uid!;
|
||||||
wkMsg.contentType = messageContent.contentType;
|
wkMsg.contentType = messageContent.contentType;
|
||||||
int tempOrderSeq = await MessaggeDB.shared
|
int tempOrderSeq = await MessageDB.shared
|
||||||
.queryMaxOrderSeq(wkMsg.channelID, wkMsg.channelType);
|
.queryMaxOrderSeq(wkMsg.channelID, wkMsg.channelType);
|
||||||
wkMsg.orderSeq = tempOrderSeq + 1;
|
wkMsg.orderSeq = tempOrderSeq + 1;
|
||||||
dynamic json = wkMsg.messageContent!.encodeJson();
|
dynamic json = wkMsg.messageContent!.encodeJson();
|
||||||
@ -445,7 +468,7 @@ class WKMessageManager {
|
|||||||
|
|
||||||
updateSendResult(
|
updateSendResult(
|
||||||
String messageID, int clientSeq, int messageSeq, int reasonCode) async {
|
String messageID, int clientSeq, int messageSeq, int reasonCode) async {
|
||||||
WKMsg? wkMsg = await MessaggeDB.shared.queryWithClientSeq(clientSeq);
|
WKMsg? wkMsg = await MessageDB.shared.queryWithClientSeq(clientSeq);
|
||||||
if (wkMsg != null) {
|
if (wkMsg != null) {
|
||||||
wkMsg.messageID = messageID;
|
wkMsg.messageID = messageID;
|
||||||
wkMsg.messageSeq = messageSeq;
|
wkMsg.messageSeq = messageSeq;
|
||||||
@ -457,7 +480,7 @@ class WKMessageManager {
|
|||||||
int orderSeq = await WKIM.shared.messageManager
|
int orderSeq = await WKIM.shared.messageManager
|
||||||
.getMessageOrderSeq(messageSeq, wkMsg.channelID, wkMsg.channelType);
|
.getMessageOrderSeq(messageSeq, wkMsg.channelID, wkMsg.channelType);
|
||||||
map['order_seq'] = orderSeq;
|
map['order_seq'] = orderSeq;
|
||||||
MessaggeDB.shared.updateMsgWithField(map, clientSeq);
|
MessageDB.shared.updateMsgWithField(map, clientSeq);
|
||||||
setRefreshMsg(wkMsg);
|
setRefreshMsg(wkMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,9 +488,9 @@ class WKMessageManager {
|
|||||||
updateMsgStatusFail(int clientMsgSeq) async {
|
updateMsgStatusFail(int clientMsgSeq) async {
|
||||||
var map = <String, Object>{};
|
var map = <String, Object>{};
|
||||||
map['status'] = WKSendMsgResult.sendFail;
|
map['status'] = WKSendMsgResult.sendFail;
|
||||||
int row = await MessaggeDB.shared.updateMsgWithField(map, clientMsgSeq);
|
int row = await MessageDB.shared.updateMsgWithField(map, clientMsgSeq);
|
||||||
if (row > 0) {
|
if (row > 0) {
|
||||||
MessaggeDB.shared.queryWithClientSeq(clientMsgSeq).then((wkMsg) {
|
MessageDB.shared.queryWithClientSeq(clientMsgSeq).then((wkMsg) {
|
||||||
if (wkMsg != null) {
|
if (wkMsg != null) {
|
||||||
setRefreshMsg(wkMsg);
|
setRefreshMsg(wkMsg);
|
||||||
}
|
}
|
||||||
@ -477,14 +500,14 @@ class WKMessageManager {
|
|||||||
|
|
||||||
updateContent(String clientMsgNO, WKMessageContent messageContent,
|
updateContent(String clientMsgNO, WKMessageContent messageContent,
|
||||||
bool isRefreshUI) async {
|
bool isRefreshUI) async {
|
||||||
WKMsg? wkMsg = await MessaggeDB.shared.queryWithClientMsgNo(clientMsgNO);
|
WKMsg? wkMsg = await MessageDB.shared.queryWithClientMsgNo(clientMsgNO);
|
||||||
if (wkMsg != null) {
|
if (wkMsg != null) {
|
||||||
var map = <String, Object>{};
|
var map = <String, Object>{};
|
||||||
dynamic json = messageContent.encodeJson();
|
dynamic json = messageContent.encodeJson();
|
||||||
json['type'] = wkMsg.contentType;
|
json['type'] = wkMsg.contentType;
|
||||||
|
|
||||||
map['content'] = jsonEncode(json);
|
map['content'] = jsonEncode(json);
|
||||||
int result = await MessaggeDB.shared
|
int result = await MessageDB.shared
|
||||||
.updateMsgWithFieldAndClientMsgNo(map, clientMsgNO);
|
.updateMsgWithFieldAndClientMsgNo(map, clientMsgNO);
|
||||||
if (isRefreshUI && result > 0) {
|
if (isRefreshUI && result > 0) {
|
||||||
setRefreshMsg(wkMsg);
|
setRefreshMsg(wkMsg);
|
||||||
@ -493,6 +516,33 @@ class WKMessageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateSendingMsgFail() {
|
updateSendingMsgFail() {
|
||||||
MessaggeDB.shared.updateSendingMsgFail();
|
MessageDB.shared.updateSendingMsgFail();
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteWithClientMsgNo(String clientMsgNo) async {
|
||||||
|
var map = <String, Object>{};
|
||||||
|
map['is_deleted'] = 1;
|
||||||
|
|
||||||
|
var result = await MessageDB.shared
|
||||||
|
.updateMsgWithFieldAndClientMsgNo(map, clientMsgNo);
|
||||||
|
if (result > 0) {
|
||||||
|
_setDeleteMsg(clientMsgNo);
|
||||||
|
var wkMsg = await getWithClientMsgNo(clientMsgNo);
|
||||||
|
if (wkMsg != null) {
|
||||||
|
var coverMsg = await ConversationDB.shared
|
||||||
|
.queryMsgByMsgChannelId(wkMsg.channelID, wkMsg.channelType);
|
||||||
|
if (coverMsg != null && coverMsg.lastClientMsgNO == clientMsgNo) {
|
||||||
|
var tempMsg = await MessageDB.shared.queryMaxOrderSeqMsgWithChannel(
|
||||||
|
wkMsg.channelID, wkMsg.channelType);
|
||||||
|
if (tempMsg != null) {
|
||||||
|
var uiMsg =
|
||||||
|
await WKIM.shared.conversationManager.saveWithLiMMsg(tempMsg);
|
||||||
|
if (uiMsg != null) {
|
||||||
|
WKIM.shared.conversationManager.setRefreshMsg(uiMsg, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ description: wukong IM flutter sdk
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# 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
|
# 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.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.1.2
|
version: 1.1.3
|
||||||
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user