Modify Query History Message

This commit is contained in:
SL 2023-09-05 21:56:25 +08:00
parent a5c5d6cb96
commit 37768f3745
9 changed files with 67 additions and 15 deletions

View File

@ -15,4 +15,6 @@
### 1.0.7 ### 1.0.7
* Support message receipts * Support message receipts
### 1.0.8 ### 1.0.8
* Modify Query History Message * Modify Query History Message
### 1.0.9
* Optimize Query History Message

View File

@ -9,7 +9,7 @@
#### 安装 #### 安装
``` ```
dependencies: dependencies:
wukongimfluttersdk: ^1.0.8 wukongimfluttersdk: ^1.0.9
``` ```
#### 引入 #### 引入
```dart ```dart

View File

@ -58,8 +58,8 @@ class ChatListDataState extends State<ChatList> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
getMsgList();
initListener(); initListener();
getMsgList(50000, 0, true);
} }
initListener() { initListener() {
@ -117,16 +117,48 @@ class ChatListDataState extends State<ChatList> {
} }
} }
getMsgList() { getPrevious() {
WKIM.shared.messageManager.getOrSyncHistoryMessages( var oldOrderSeq = 0;
channelID, channelType, 0, true, 0, 100, 0, (list) { for (var msg in msgList) {
if (oldOrderSeq == 0 || oldOrderSeq > msg.wkMsg.orderSeq) {
oldOrderSeq = msg.wkMsg.orderSeq;
}
}
getMsgList(oldOrderSeq, 0, false);
}
getLast() {
var oldOrderSeq = 0;
for (var msg in msgList) {
if (oldOrderSeq == 0 || oldOrderSeq < msg.wkMsg.orderSeq) {
oldOrderSeq = msg.wkMsg.orderSeq;
}
}
getMsgList(oldOrderSeq, 1, false);
}
getMsgList(int oldestOrderSeq, int pullMode, bool isReset) {
WKIM.shared.messageManager.getOrSyncHistoryMessages(channelID, channelType,
oldestOrderSeq, oldestOrderSeq == 0, pullMode, 20, 0, (list) {
List<UIMsg> uiList = [];
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
msgList.add(UIMsg(list[i])); print(list[i].orderSeq);
if (pullMode == 0 && !isReset) {
uiList.add(UIMsg(list[i]));
// msgList.insert(0, UIMsg(list[i]));
} else {
msgList.add(UIMsg(list[i]));
}
}
if (uiList.isNotEmpty) {
msgList.insertAll(0, uiList);
} }
setState(() {}); setState(() {});
Future.delayed(const Duration(milliseconds: 300), () { if (isReset) {
_scrollController.jumpTo(_scrollController.position.maxScrollExtent); Future.delayed(const Duration(milliseconds: 300), () {
}); _scrollController.jumpTo(_scrollController.position.maxScrollExtent);
});
}
}, () { }, () {
print('消息同步中'); print('消息同步中');
}); });
@ -295,6 +327,22 @@ class ChatListDataState extends State<ChatList> {
decoration: const InputDecoration(hintText: '请输入内容'), decoration: const InputDecoration(hintText: '请输入内容'),
autofocus: true), autofocus: true),
), ),
MaterialButton(
onPressed: () {
getPrevious();
},
color: Colors.brown,
child:
const Text("上一页", style: TextStyle(color: Colors.white)),
),
MaterialButton(
onPressed: () {
getLast();
},
color: Colors.brown,
child:
const Text("下一页", style: TextStyle(color: Colors.white)),
),
MaterialButton( MaterialButton(
onPressed: () { onPressed: () {
if (content != '') { if (content != '') {

View File

@ -38,7 +38,7 @@ class HttpUtils {
"version": version, // (version0) "version": version, // (version0)
"last_msg_seqs": "last_msg_seqs":
lastSsgSeqs, // channelID:channelType:last_msg_seq|channelID:channelType:last_msg_seq lastSsgSeqs, // channelID:channelType:last_msg_seq|channelID:channelType:last_msg_seq
"msg_count": 20 // app点进去第一屏的数据 "msg_count": 10 // app点进去第一屏的数据
}); });
WKSyncConversation conversation = WKSyncConversation(); WKSyncConversation conversation = WKSyncConversation();
conversation.conversations = []; conversation.conversations = [];

View File

@ -15,7 +15,8 @@ class UIMsg {
if (wkMsg.wkMsgExtra != null) { if (wkMsg.wkMsgExtra != null) {
readCount = wkMsg.wkMsgExtra!.readedCount; readCount = wkMsg.wkMsgExtra!.readedCount;
} }
return "${wkMsg.messageContent!.displayText()} [是否需要回执:${wkMsg.setting.receipt}][已读数量:$readCount]"; return wkMsg.messageContent!.displayText();
// return "${wkMsg.messageContent!.displayText()} [是否需要回执:${wkMsg.setting.receipt}][已读数量:$readCount]";
} }
String getShowTime() { String getShowTime() {

View File

@ -499,7 +499,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.0.8" version: "1.0.9"
x25519: x25519:
dependency: transitive dependency: transitive
description: description:

View File

@ -434,7 +434,7 @@ class MessaggeDB {
Future<int> getDeletedCount(int minMessageSeq, int maxMessageSeq, Future<int> getDeletedCount(int minMessageSeq, int maxMessageSeq,
String channelID, int channelType) async { String channelID, int channelType) async {
String sql = String sql =
"select count(*) num from ${WKDBConst.tableMessage} where channel_id=$channelID and channel_type=$channelType and message_seq>$minMessageSeq and message_seq<$maxMessageSeq and is_deleted=1"; "select count(*) num from ${WKDBConst.tableMessage} where channel_id='$channelID' and channel_type=$channelType and message_seq>$minMessageSeq and message_seq<$maxMessageSeq and is_deleted=1";
int num = 0; int num = 0;
List<Map<String, Object?>> list = List<Map<String, Object?>> list =
await WKDBHelper.shared.getDB().rawQuery(sql); await WKDBHelper.shared.getDB().rawQuery(sql);

View File

@ -39,6 +39,7 @@ class WKMsg {
WKMessageContent? messageContent; WKMessageContent? messageContent;
WKMsg() { WKMsg() {
clientSeq = 0;
clientMsgNO = WKIM.shared.messageManager.generateClientMsgNo(); clientMsgNO = WKIM.shared.messageManager.generateClientMsgNo();
timestamp = (DateTime.now().millisecondsSinceEpoch / 1000).truncate(); timestamp = (DateTime.now().millisecondsSinceEpoch / 1000).truncate();
} }

View File

@ -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.0.8 version: 1.0.9
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
environment: environment: