fix:Add send message can reminder member method

This commit is contained in:
SL 2024-04-25 21:48:29 +08:00
parent 1ea17b9cdb
commit 0398d2b015
12 changed files with 129 additions and 8 deletions

View File

@ -71,4 +71,6 @@
### 1.3.5
* fix: Add clear channel messages method
### 1.3.6
* fix: Add clear all channel red dots method
* fix: Add clear all channel red dots method
### 1.3.7
* fix: Add send message can reminder member method

View File

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

View File

@ -151,6 +151,7 @@ class ChatListDataState extends State<ChatList> {
oldestOrderSeq, oldestOrderSeq == 0, pullMode, 10, 0, (list) {
List<UIMsg> uiList = [];
for (int i = 0; i < list.length; i++) {
print(list[i].content);
if (pullMode == 0 && !isReset) {
uiList.add(UIMsg(list[i]));
// msgList.insert(0, UIMsg(list[i]));
@ -368,6 +369,7 @@ class ChatListDataState extends State<ChatList> {
_textEditingController.text = '';
Setting setting = Setting();
setting.receipt = 1; //
//
WKTextContent text = WKTextContent(content);
WKReply reply = WKReply();
reply.messageId = "11";
@ -377,6 +379,7 @@ class ChatListDataState extends State<ChatList> {
WKTextContent payloadText = WKTextContent("dds");
reply.payload = payloadText;
text.reply = reply;
//
List<WKMsgEntity> list = [];
WKMsgEntity entity = WKMsgEntity();
entity.offset = 0;
@ -384,6 +387,11 @@ class ChatListDataState extends State<ChatList> {
entity.length = 1;
list.add(entity);
text.entities = list;
//
WKMentionInfo mentionInfo = WKMentionInfo();
mentionInfo.mentionAll = true;
mentionInfo.uids = ['uid_1', 'uid_2'];
text.mentionInfo = mentionInfo;
// CustomMsg customMsg = CustomMsg(content);
WKIM.shared.messageManager.sendMessageWithSetting(
text, WKChannel(channelID, channelType), setting);

View File

@ -4,6 +4,7 @@ class UIConversation {
String lastContent = '';
String channelAvatar = '';
String channelName = '';
int isMentionMe = 0;
WKUIConversationMsg msg;
UIConversation(this.msg);

View File

@ -1,6 +1,7 @@
import 'package:example/const.dart';
import 'package:flutter/material.dart';
import 'package:wukongimfluttersdk/entity/conversation.dart';
import 'package:wukongimfluttersdk/entity/reminder.dart';
import 'package:wukongimfluttersdk/type/const.dart';
import 'package:wukongimfluttersdk/wkim.dart';
@ -127,6 +128,28 @@ class ListViewShowDataState extends State<ListViewShowData> {
return uiConversation.lastContent;
}
String getReminderText(UIConversation uiConversation) {
String content = "";
if (uiConversation.isMentionMe == 0) {
uiConversation.msg.getReminderList().then((value) {
if (value != null && value.isNotEmpty) {
for (var i = 0; i < value.length; i++) {
if (value[i].type == WKMentionType.wkReminderTypeMentionMe &&
value[i].done == 0) {
content = value[i].data;
uiConversation.isMentionMe = 1;
setState(() {});
break;
}
}
}
});
} else {
content = "[有人@你]";
}
return content;
}
String getChannelAvatarURL(UIConversation uiConversation) {
if (uiConversation.channelAvatar == '') {
uiConversation.msg.getWkChannel().then((channel) {
@ -207,6 +230,13 @@ class ListViewShowDataState extends State<ListViewShowData> {
),
Row(
children: [
Text(
getReminderText(uiMsg),
style: const TextStyle(
color: Color.fromARGB(255, 247, 2, 2),
fontSize: 14),
maxLines: 1,
),
Text(
getShowContent(uiMsg),
style:
@ -245,7 +275,7 @@ class ListViewShowDataState extends State<ListViewShowData> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChatPage(),
builder: (context) => const ChatPage(),
settings: RouteSettings(
arguments: ChatChannel(
msgList[pos].msg.channelID,
@ -274,7 +304,35 @@ class ListViewShowDataState extends State<ListViewShowData> {
WKIM.shared.conversationManager.clearAllRedDot();
},
child: const Text(
'清除所有未读',
'清除未读',
style: TextStyle(color: Colors.white),
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 240, 2, 133),
),
onPressed: () {
if (msgList.isEmpty) {
return;
}
List<WKReminder> list = [];
WKReminder reminder = WKReminder();
reminder.needUpload = 0;
reminder.type = WKMentionType.wkReminderTypeMentionMe;
reminder.data = '[有人@你]';
reminder.done = 0;
reminder.reminderID = 11;
reminder.version = 1;
reminder.publisher = "uid_1";
reminder.channelID = msgList[0].msg.channelID;
reminder.channelType = msgList[0].msg.channelType;
list.add(reminder);
WKIM.shared.reminderManager.saveOrUpdateReminders(list);
},
child: const Text(
'提醒项',
style: TextStyle(color: Colors.white),
),
),
@ -286,7 +344,7 @@ class ListViewShowDataState extends State<ListViewShowData> {
WKIM.shared.connectionManager.disconnect(false);
},
child: const Text(
'断开连接',
'断开',
style: TextStyle(color: Colors.white),
),
),

View File

@ -225,7 +225,7 @@ class WKDBConst {
reminder.version = readInt(data, 'version');
reminder.done = readInt(data, 'done');
String data1 = readString(data, 'data');
reminder.needUpload = readInt(data, 'needUpload');
reminder.needUpload = readInt(data, 'need_upload');
reminder.publisher = readString(data, 'publisher');
if (data1 != '') {
reminder.data = jsonDecode(data1);

View File

@ -177,7 +177,7 @@ class ReminderDB {
map['text'] = reminder.text;
map['version'] = reminder.version;
map['done'] = reminder.done;
map['needUpload'] = reminder.needUpload;
map['need_upload'] = reminder.needUpload;
map['publisher'] = reminder.publisher;
if (reminder.data != null) {
map['data'] = jsonEncode(reminder.data);

View File

@ -286,3 +286,9 @@ class WKSyncChannelMsg {
int more = 0;
List<WKSyncMsg>? messages = [];
}
class WKMentionInfo {
bool isMentionMe = false;
bool mentionAll = false;
List<String>? uids;
}

View File

@ -14,3 +14,10 @@ class WKReminder {
int needUpload = 0;
String publisher = '';
}
class WKMentionType {
//@
static const int wkReminderTypeMentionMe = 1;
//
static const int wkApplyJoinGroupApprove = 2;
}

View File

@ -81,6 +81,28 @@ class WKMessageManager {
}
content.entities = list;
}
//
var mentionJson = json['mention'];
if (mentionJson != null) {
var mentionInfo = WKMentionInfo();
var mentionAll = WKDBConst.readInt(mentionJson, 'all');
var uidList = mentionJson['uids'];
if (uidList != null) {
List<String> uids = [];
for (var uid in uidList) {
uids.add(uid);
if (uid == WKIM.shared.options.uid) {
mentionInfo.isMentionMe = true;
}
}
mentionInfo.uids = uids;
}
if (mentionAll == 1) {
mentionInfo.mentionAll = true;
mentionInfo.isMentionMe = true;
}
content.mentionInfo = mentionInfo;
}
return content;
}
@ -617,6 +639,22 @@ class WKMessageManager {
}
json['entities'] = jsonArray;
}
//
if (wkMsg.messageContent!.mentionInfo != null) {
var mentionJson = {};
if (wkMsg.messageContent!.mentionInfo!.mentionAll) {
mentionJson['all'] = 1;
}
if (wkMsg.messageContent!.mentionInfo!.uids != null &&
wkMsg.messageContent!.mentionInfo!.uids!.isNotEmpty) {
var jsonArray = [];
for (String uid in wkMsg.messageContent!.mentionInfo!.uids!) {
jsonArray.add(uid);
}
mentionJson['uids'] = jsonArray;
}
json['mention'] = mentionJson;
}
return jsonEncode(json);
}

View File

@ -6,6 +6,7 @@ class WKMessageContent {
String topicId = "";
WKReply? reply;
List<WKMsgEntity>? entities;
WKMentionInfo? mentionInfo;
Map<String, dynamic> encodeJson() {
return {};
}

View File

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