mirror of
https://github.com/WuKongIM/WuKongIMFlutterSDK
synced 2025-05-29 15:12:20 +00:00
fix:Add query total unread quantity and query followed channels
This commit is contained in:
parent
479f64bd34
commit
59a17bdf56
@ -113,4 +113,6 @@
|
|||||||
### 1.5.6
|
### 1.5.6
|
||||||
* fix: Optimize reconnection and resend messages
|
* fix: Optimize reconnection and resend messages
|
||||||
### 1.5.7
|
### 1.5.7
|
||||||
* fix: Optimize channel fields in cmd messages
|
* fix: Optimize channel fields in cmd messages
|
||||||
|
### 1.5.8
|
||||||
|
* fix: Add query total unread quantity and query followed channels
|
@ -89,8 +89,12 @@ class ChatListDataState extends State<ChatList> {
|
|||||||
|
|
||||||
// 监听新消息
|
// 监听新消息
|
||||||
WKIM.shared.messageManager.addOnNewMsgListener('chat', (msgs) {
|
WKIM.shared.messageManager.addOnNewMsgListener('chat', (msgs) {
|
||||||
|
print('收到${msgs.length}条新消息');
|
||||||
setState(() {
|
setState(() {
|
||||||
for (var i = 0; i < msgs.length; i++) {
|
for (var i = 0; i < msgs.length; i++) {
|
||||||
|
if (msgs[i].channelID != channelID) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (msgs[i].setting.receipt == 1) {
|
if (msgs[i].setting.receipt == 1) {
|
||||||
// 消息需要回执
|
// 消息需要回执
|
||||||
testReceipt(msgs[i]);
|
testReceipt(msgs[i]);
|
||||||
|
@ -142,6 +142,33 @@ class ChannelDB {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<WKChannel>> queryWithFollowAndStatus(
|
||||||
|
int channelType, int follow, int status) async {
|
||||||
|
List<WKChannel> list = [];
|
||||||
|
var sql =
|
||||||
|
"select * from ${WKDBConst.tableChannel} where channel_type=? and follow=? and status=? and is_deleted=0";
|
||||||
|
List<Map<String, Object?>> results = await WKDBHelper.shared
|
||||||
|
.getDB()!
|
||||||
|
.rawQuery(sql, [channelType, follow, status]);
|
||||||
|
for (Map<String, Object?> data in results) {
|
||||||
|
var channel = WKDBConst.serializeChannel(data);
|
||||||
|
list.add(channel);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<WKChannel>> queryWithMuted() async {
|
||||||
|
List<WKChannel> list = [];
|
||||||
|
var sql = "select * from ${WKDBConst.tableChannel} where mute=1";
|
||||||
|
List<Map<String, Object?>> results =
|
||||||
|
await WKDBHelper.shared.getDB()!.rawQuery(sql);
|
||||||
|
for (Map<String, Object?> data in results) {
|
||||||
|
var channel = WKDBConst.serializeChannel(data);
|
||||||
|
list.add(channel);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<WKChannel>> searchWithChannelTypeAndFollow(
|
Future<List<WKChannel>> searchWithChannelTypeAndFollow(
|
||||||
String keyword, int channelType, int follow) async {
|
String keyword, int channelType, int follow) async {
|
||||||
List<WKChannel> list = [];
|
List<WKChannel> list = [];
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:collection';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
import 'package:wukongimfluttersdk/db/channel.dart';
|
||||||
import 'package:wukongimfluttersdk/db/const.dart';
|
import 'package:wukongimfluttersdk/db/const.dart';
|
||||||
import 'package:wukongimfluttersdk/entity/channel.dart';
|
import 'package:wukongimfluttersdk/entity/channel.dart';
|
||||||
|
|
||||||
@ -94,6 +95,31 @@ class ConversationDB {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> queryAllUnreadCount() async {
|
||||||
|
int count = 0;
|
||||||
|
var channels = await ChannelDB.shared.queryWithMuted();
|
||||||
|
var channelIds = [];
|
||||||
|
var sql = "";
|
||||||
|
List<Map<String, Object?>> list;
|
||||||
|
if (channels.isNotEmpty) {
|
||||||
|
for (var channel in channels) {
|
||||||
|
channelIds.add(channel.channelID);
|
||||||
|
}
|
||||||
|
sql =
|
||||||
|
"select COUNT(unread_count) count from ${WKDBConst.tableConversation} where channel_id not in (${WKDBConst.getPlaceholders(channelIds.length)})";
|
||||||
|
list = await WKDBHelper.shared.getDB()!.rawQuery(sql, channelIds);
|
||||||
|
} else {
|
||||||
|
sql =
|
||||||
|
"select COUNT(unread_count) count from ${WKDBConst.tableConversation}";
|
||||||
|
list = await WKDBHelper.shared.getDB()!.rawQuery(sql);
|
||||||
|
}
|
||||||
|
if (list.isNotEmpty) {
|
||||||
|
dynamic data = list[0];
|
||||||
|
count = WKDBConst.readInt(data, 'count');
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> getMaxVersion() async {
|
Future<int> getMaxVersion() async {
|
||||||
int maxVersion = 0;
|
int maxVersion = 0;
|
||||||
if (WKDBHelper.shared.getDB() == null) {
|
if (WKDBHelper.shared.getDB() == null) {
|
||||||
|
@ -22,6 +22,12 @@ class WKChannelManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<WKChannel>> getWithFollowAndStatus(
|
||||||
|
int channelType, int follow, int status) async {
|
||||||
|
return ChannelDB.shared
|
||||||
|
.queryWithFollowAndStatus(channelType, follow, status);
|
||||||
|
}
|
||||||
|
|
||||||
Future<WKChannel?> getChannel(String channelID, int channelType) async {
|
Future<WKChannel?> getChannel(String channelID, int channelType) async {
|
||||||
WKChannel? channel;
|
WKChannel? channel;
|
||||||
if (_list.isNotEmpty) {
|
if (_list.isNotEmpty) {
|
||||||
|
@ -58,6 +58,10 @@ class WKConversationManager {
|
|||||||
return uiMsg;
|
return uiMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> getAllUnreadCount() async {
|
||||||
|
return ConversationDB.shared.queryAllUnreadCount();
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> getExtraMaxVersion() async {
|
Future<int> getExtraMaxVersion() async {
|
||||||
return ConversationDB.shared.queryExtraMaxVersion();
|
return ConversationDB.shared.queryExtraMaxVersion();
|
||||||
}
|
}
|
||||||
|
@ -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.5.7
|
version: 1.5.8
|
||||||
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user