mirror of
https://github.com/WuKongIM/WuKongIMFlutterSDK
synced 2025-05-30 07:27:25 +00:00
fix:add clear all unread count method
This commit is contained in:
parent
87fb40796a
commit
1ea17b9cdb
@ -69,4 +69,6 @@
|
|||||||
### 1.3.4
|
### 1.3.4
|
||||||
* fix: Optimize connections
|
* fix: Optimize connections
|
||||||
### 1.3.5
|
### 1.3.5
|
||||||
* fix: Add clear channel messages method
|
* fix: Add clear channel messages method
|
||||||
|
### 1.3.6
|
||||||
|
* fix: Add clear all channel red dots method
|
@ -9,7 +9,7 @@
|
|||||||
#### 安装
|
#### 安装
|
||||||
```
|
```
|
||||||
dependencies:
|
dependencies:
|
||||||
wukongimfluttersdk: ^1.3.5
|
wukongimfluttersdk: ^1.3.6
|
||||||
```
|
```
|
||||||
#### 引入
|
#### 引入
|
||||||
```dart
|
```dart
|
||||||
|
@ -55,11 +55,20 @@ class ListViewShowDataState extends State<ListViewShowData> {
|
|||||||
_connectionStatusStr = '同步消息中...';
|
_connectionStatusStr = '同步消息中...';
|
||||||
} else if (status == WKConnectStatus.kicked) {
|
} else if (status == WKConnectStatus.kicked) {
|
||||||
_connectionStatusStr = '未连接,在其他设备登录';
|
_connectionStatusStr = '未连接,在其他设备登录';
|
||||||
|
} else if (status == WKConnectStatus.fail) {
|
||||||
|
_connectionStatusStr = '未连接';
|
||||||
}
|
}
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
WKIM.shared.conversationManager
|
||||||
|
.addOnClearAllRedDotListener("chat_conversation", () {
|
||||||
|
for (var i = 0; i < msgList.length; i++) {
|
||||||
|
msgList[i].msg.unreadCount = 0;
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
// 监听更新消息事件
|
// 监听更新消息事件
|
||||||
WKIM.shared.conversationManager.addOnRefreshMsgListener('chat_conversation',
|
WKIM.shared.conversationManager.addOnRefreshMsgListener('chat_conversation',
|
||||||
(msg, isEnd) async {
|
(msg, isEnd) async {
|
||||||
@ -256,6 +265,44 @@ class ListViewShowDataState extends State<ListViewShowData> {
|
|||||||
tooltip: 'Increment',
|
tooltip: 'Increment',
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
|
persistentFooterButtons: [
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: const Color.fromARGB(255, 240, 117, 2),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
WKIM.shared.conversationManager.clearAllRedDot();
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'清除所有未读',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
WKIM.shared.connectionManager.disconnect(false);
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'断开连接',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: const Color.fromARGB(255, 31, 27, 239),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
WKIM.shared.connectionManager.connect();
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'重连',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +191,14 @@ class ConversationDB {
|
|||||||
return maxVersion;
|
return maxVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> clearAllRedDot() async {
|
||||||
|
var map = <String, Object>{};
|
||||||
|
map['unread_count'] = 0;
|
||||||
|
return await WKDBHelper.shared
|
||||||
|
.getDB()
|
||||||
|
.update(WKDBConst.tableConversation, map, where: "unread_count>0");
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> updateWithField(
|
Future<int> updateWithField(
|
||||||
dynamic map, String channelID, int channelType) async {
|
dynamic map, String channelID, int channelType) async {
|
||||||
return await WKDBHelper.shared.getDB().update(
|
return await WKDBHelper.shared.getDB().update(
|
||||||
|
@ -135,6 +135,8 @@ class WKConnectionManager {
|
|||||||
WKDBHelper.shared.close();
|
WKDBHelper.shared.close();
|
||||||
}
|
}
|
||||||
_closeAll();
|
_closeAll();
|
||||||
|
WKIM.shared.connectionManager
|
||||||
|
.setConnectionStatus(WKConnectStatus.fail, "Actively disconnect");
|
||||||
}
|
}
|
||||||
|
|
||||||
_socketConnect(String addr) {
|
_socketConnect(String addr) {
|
||||||
|
@ -17,6 +17,7 @@ class WKConversationManager {
|
|||||||
|
|
||||||
HashMap<String, Function(WKUIConversationMsg, bool)>? _refeshMsgMap;
|
HashMap<String, Function(WKUIConversationMsg, bool)>? _refeshMsgMap;
|
||||||
HashMap<String, Function(String, int)>? _deleteMsgMap;
|
HashMap<String, Function(String, int)>? _deleteMsgMap;
|
||||||
|
HashMap<String, Function()>? _clearAllRedDotMap;
|
||||||
|
|
||||||
Function(String lastSsgSeqs, int msgCount, int version,
|
Function(String lastSsgSeqs, int msgCount, int version,
|
||||||
Function(WKSyncConversation))? _syncConersationBack;
|
Function(WKSyncConversation))? _syncConersationBack;
|
||||||
@ -74,6 +75,13 @@ class WKConversationManager {
|
|||||||
ConversationDB.shared.clearAll();
|
ConversationDB.shared.clearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAllRedDot() async {
|
||||||
|
int row = await ConversationDB.shared.clearAllRedDot();
|
||||||
|
if (row > 0) {
|
||||||
|
_setClearAllRedDot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateRedDot(String channelID, int channelType, int redDot) async {
|
updateRedDot(String channelID, int channelType, int redDot) async {
|
||||||
var map = <String, Object>{};
|
var map = <String, Object>{};
|
||||||
map['unread_count'] = redDot;
|
map['unread_count'] = redDot;
|
||||||
@ -93,6 +101,25 @@ class WKConversationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addOnClearAllRedDotListener(String key, Function() back) {
|
||||||
|
_clearAllRedDotMap ??= HashMap();
|
||||||
|
_clearAllRedDotMap![key] = back;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeClearAllRedDotListener(String key) {
|
||||||
|
if (_clearAllRedDotMap != null) {
|
||||||
|
_clearAllRedDotMap!.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_setClearAllRedDot() {
|
||||||
|
if (_clearAllRedDotMap != null) {
|
||||||
|
_clearAllRedDotMap!.forEach((key, back) {
|
||||||
|
back();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addOnDeleteMsgListener(String key, Function(String, int) back) {
|
addOnDeleteMsgListener(String key, Function(String, int) back) {
|
||||||
_deleteMsgMap ??= HashMap();
|
_deleteMsgMap ??= HashMap();
|
||||||
_deleteMsgMap![key] = back;
|
_deleteMsgMap![key] = back;
|
||||||
|
@ -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.5
|
version: 1.3.6
|
||||||
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user