mirror of
https://github.com/WuKongIM/WuKongIMFlutterSDK
synced 2025-05-30 15:37:25 +00:00
fix:add clear channel message method
This commit is contained in:
parent
e2d170e9f0
commit
87fb40796a
@ -66,5 +66,7 @@
|
|||||||
* fix: Optimization of loading channel messages without the latest messages and multiple synchronization issues
|
* fix: Optimization of loading channel messages without the latest messages and multiple synchronization issues
|
||||||
### 1.3.3
|
### 1.3.3
|
||||||
* fix: Optimization of loading channel messages without the latest messages and multiple synchronization issues
|
* fix: Optimization of loading channel messages without the latest messages and multiple synchronization issues
|
||||||
### 1.2.4
|
### 1.3.4
|
||||||
* fix: Optimize connections
|
* fix: Optimize connections
|
||||||
|
### 1.3.5
|
||||||
|
* fix: Add clear channel messages method
|
@ -9,7 +9,7 @@
|
|||||||
#### 安装
|
#### 安装
|
||||||
```
|
```
|
||||||
dependencies:
|
dependencies:
|
||||||
wukongimfluttersdk: ^1.3.4
|
wukongimfluttersdk: ^1.3.5
|
||||||
```
|
```
|
||||||
#### 引入
|
#### 引入
|
||||||
```dart
|
```dart
|
||||||
|
@ -98,6 +98,14 @@ class ChatListDataState extends State<ChatList> {
|
|||||||
}
|
}
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
|
// 清除聊天记录
|
||||||
|
WKIM.shared.messageManager.addOnClearChannelMsgListener("chat",
|
||||||
|
(channelId, channelType) {
|
||||||
|
if (channelID == channelId) {
|
||||||
|
msgList.clear();
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模拟同步消息扩展后保存到db
|
// 模拟同步消息扩展后保存到db
|
||||||
@ -304,20 +312,13 @@ class ChatListDataState extends State<ChatList> {
|
|||||||
actions: [
|
actions: [
|
||||||
MaterialButton(
|
MaterialButton(
|
||||||
child: const Text(
|
child: const Text(
|
||||||
'断开',
|
'清空记录',
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Color.fromARGB(255, 4, 80, 194)),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
WKIM.shared.connectionManager.disconnect(false);
|
WKIM.shared.messageManager
|
||||||
|
.clearWithChannel(channelID, channelType);
|
||||||
}),
|
}),
|
||||||
MaterialButton(
|
|
||||||
child: const Text(
|
|
||||||
'重连',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
WKIM.shared.connectionManager.connect();
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
|
@ -80,7 +80,6 @@ class HttpUtils {
|
|||||||
int pullMode,
|
int pullMode,
|
||||||
Function(WKSyncChannelMsg) back) async {
|
Function(WKSyncChannelMsg) back) async {
|
||||||
final dio = Dio();
|
final dio = Dio();
|
||||||
print('同不消息');
|
|
||||||
final response = await dio.post('$apiURL/channel/messagesync', data: {
|
final response = await dio.post('$apiURL/channel/messagesync', data: {
|
||||||
"login_uid": UserInfo.uid, // 当前登录用户uid
|
"login_uid": UserInfo.uid, // 当前登录用户uid
|
||||||
"channel_id": channelID, // 频道ID
|
"channel_id": channelID, // 频道ID
|
||||||
|
@ -321,6 +321,12 @@ class MessageDB {
|
|||||||
//获取原始数据
|
//获取原始数据
|
||||||
List<WKMsg> list = await getMessages(
|
List<WKMsg> list = await getMessages(
|
||||||
channelId, channelType, oldestOrderSeq, contain, pullMode, limit);
|
channelId, channelType, oldestOrderSeq, contain, pullMode, limit);
|
||||||
|
if (isMore == 0) {
|
||||||
|
iGetOrSyncHistoryMsgBack(list);
|
||||||
|
isMore = 1;
|
||||||
|
requestCount = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
//业务判断数据
|
//业务判断数据
|
||||||
List<WKMsg> tempList = [];
|
List<WKMsg> tempList = [];
|
||||||
for (int i = 0, size = list.length; i < size; i++) {
|
for (int i = 0, size = list.length; i < size; i++) {
|
||||||
@ -729,6 +735,14 @@ class MessageDB {
|
|||||||
return wkMsg;
|
return wkMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> deleteWithChannel(String channelId, int channelType) async {
|
||||||
|
var map = <String, Object>{};
|
||||||
|
map['is_deleted'] = 1;
|
||||||
|
return await WKDBHelper.shared.getDB().update(WKDBConst.tableMessage, map,
|
||||||
|
where: "channel_id=? and channel_type=?",
|
||||||
|
whereArgs: [channelId, channelType]);
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -34,7 +34,7 @@ class WKMessageManager {
|
|||||||
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;
|
HashMap<String, Function(String)>? _deleteMsgBack;
|
||||||
|
HashMap<String, Function(String, int)>? _clearChannelMsgBack;
|
||||||
Function(
|
Function(
|
||||||
String channelID,
|
String channelID,
|
||||||
int channelType,
|
int channelType,
|
||||||
@ -396,6 +396,27 @@ class WKMessageManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addOnClearChannelMsgListener(String key, Function(String, int) back) {
|
||||||
|
_clearChannelMsgBack ??= HashMap();
|
||||||
|
if (key != '') {
|
||||||
|
_clearChannelMsgBack![key] = back;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
removeClearChannelMsgListener(String key) {
|
||||||
|
if (_clearChannelMsgBack != null) {
|
||||||
|
_clearChannelMsgBack!.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_setClearChannelMsg(String channelID, int channelType) {
|
||||||
|
if (_clearChannelMsgBack != null) {
|
||||||
|
_clearChannelMsgBack!.forEach((key, back) {
|
||||||
|
back(channelID, channelType);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addOnDeleteMsgListener(String key, Function(String) back) {
|
addOnDeleteMsgListener(String key, Function(String) back) {
|
||||||
_deleteMsgBack ??= HashMap();
|
_deleteMsgBack ??= HashMap();
|
||||||
if (key != '') {
|
if (key != '') {
|
||||||
@ -688,6 +709,13 @@ class WKMessageManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearWithChannel(String channelId, int channelType) async {
|
||||||
|
int row = await MessageDB.shared.deleteWithChannel(channelId, channelType);
|
||||||
|
if (row > 0) {
|
||||||
|
_setClearChannelMsg(channelId, channelType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deleteWithClientMsgNo(String clientMsgNo) async {
|
deleteWithClientMsgNo(String clientMsgNo) async {
|
||||||
var map = <String, Object>{};
|
var map = <String, Object>{};
|
||||||
map['is_deleted'] = 1;
|
map['is_deleted'] = 1;
|
||||||
|
@ -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.3.4
|
version: 1.3.5
|
||||||
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user