From 3900a39b669f93e70541f0e06fed0cc72601c580 Mon Sep 17 00:00:00 2001 From: SL Date: Wed, 28 Feb 2024 17:28:52 +0800 Subject: [PATCH] fix: Optimization of loading channel messages without the latest messages and multiple synchronization issues --- CHANGELOG.md | 2 ++ README.md | 2 +- example/lib/http.dart | 1 + lib/db/message.dart | 8 +++++++- pubspec.yaml | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 926bebd..aac5fa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,4 +63,6 @@ ### 1.3.1 * fix: synchronization channel message multiple synchronization issue ### 1.3.2 + * fix: Optimization of loading channel messages without the latest messages and multiple synchronization issues + ### 1.3.3 * fix: Optimization of loading channel messages without the latest messages and multiple synchronization issues \ No newline at end of file diff --git a/README.md b/README.md index 77443d8..d41c512 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ #### 安装 ``` dependencies: - wukongimfluttersdk: ^1.3.2 + wukongimfluttersdk: ^1.3.3 ``` #### 引入 ```dart diff --git a/example/lib/http.dart b/example/lib/http.dart index 26ec857..650390c 100644 --- a/example/lib/http.dart +++ b/example/lib/http.dart @@ -80,6 +80,7 @@ class HttpUtils { int pullMode, Function(WKSyncChannelMsg) back) async { final dio = Dio(); + print('同不消息'); final response = await dio.post('$apiURL/channel/messagesync', data: { "login_uid": UserInfo.uid, // 当前登录用户uid "channel_id": channelID, // 频道ID diff --git a/lib/db/message.dart b/lib/db/message.dart index 60d60ac..e7d490c 100644 --- a/lib/db/message.dart +++ b/lib/db/message.dart @@ -308,6 +308,7 @@ class MessageDB { } var requestCount = 0; + var isMore = 1; void getOrSyncHistoryMessages( String channelId, int channelType, @@ -359,7 +360,9 @@ class MessageDB { } else { oldestMsgSeq = oldestOrderSeq ~/ 1000; } - if (oldestMsgSeq == 1) { + if (oldestMsgSeq == 1 || isMore == 0) { + isMore = 1; + requestCount = 0; iGetOrSyncHistoryMsgBack(list); return; } @@ -460,15 +463,18 @@ class MessageDB { if (syncChannelMsg != null && syncChannelMsg.messages != null && syncChannelMsg.messages!.isNotEmpty) { + isMore = syncChannelMsg.more; getOrSyncHistoryMessages(channelId, channelType, oldestOrderSeq, contain, pullMode, limit, iGetOrSyncHistoryMsgBack, syncBack); } else { requestCount = 0; + isMore = 1; iGetOrSyncHistoryMsgBack(list); } }); } else { requestCount = 0; + isMore = 1; iGetOrSyncHistoryMsgBack(list); } } diff --git a/pubspec.yaml b/pubspec.yaml index ba55d9c..ebc8aa9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ description: wukong IM flutter sdk # 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 # of the product and file versions while build-number is used as the build suffix. -version: 1.3.2 +version: 1.3.3 homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK environment: