fix:Modify the import SDK method

This commit is contained in:
SL 2024-05-29 21:56:35 +08:00
parent 33880c1b47
commit 53e7be54fc
6 changed files with 34 additions and 57 deletions

View File

@ -7,9 +7,11 @@
## 快速入门
#### 安装
[![pub package](https://img.shields.io/pub/v/wukongimfluttersdk.svg)](https://pub.dartlang.org/packages/wukongimfluttersdk)
```
dependencies:
wukongimfluttersdk: ^1.4.1
wukongimfluttersdk: ^version // 版本号看上面
```
#### 引入
```dart
@ -84,4 +86,7 @@ WKIM.shared.cmdManager.addOnCmdListener('chat', (cmdMsg) {
// todo 按需处理cmd消息
});
```
- 包含`key`的事件监听均有移除监听的方法,为了避免重复收到事件回掉,在退出或销毁页面时通过传入的`key`移除事件
- 包含`key`的事件监听均有移除监听的方法,为了避免重复收到事件回掉,在退出或销毁页面时通过传入的`key`移除事件
### 许可证
悟空IM 使用 Apache 2.0 许可证。有关详情,请参阅 LICENSE 文件。

View File

@ -45,11 +45,18 @@ class ChatListDataState extends State<ChatList> {
final ScrollController _scrollController = ScrollController();
ChatListDataState(this.channelID, this.channelType) {
if (channelType == WKChannelType.group) {
title = '群聊【$channelID';
} else {
title = '单聊【$channelID';
}
WKIM.shared.channelManager
.getChannel(channelID, channelType)
.then((channel) {
print(channel?.localExtra);
print(channel?.remoteExtraMap);
WKIM.shared.channelManager.fetchChannelInfo(channelID, channelType);
if (channelType == WKChannelType.group) {
title = '${channel?.channelName}';
} else {
title = '${channel?.channelName}';
}
});
}
List<UIMsg> msgList = [];
String title = '';
@ -151,7 +158,6 @@ 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]));

View File

@ -37,7 +37,7 @@ class IMUtils {
"https://lmg.jj20.com/up/allimg/tx28/430423183653303.jpg",
"https://lmg.jj20.com/up/allimg/tx23/520420024834916.jpg",
"https://himg.bdimg.com/sys/portraitn/item/public.1.a535a65d.tJe8MgWmP8zJ456B73Kzfg",
"https://images.liqucn.com/img/h23/h07/img_localize_cb7b78b88d5b33e2ce8921221bf3deae_400x400.png",
"https://img2.baidu.com/it/u=3324164588,1070151830&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500",
"https://img1.baidu.com/it/u=3916753633,2634890492&fm=253&fmt=auto&app=138&f=JPEG?w=400&h=400",
"https://img0.baidu.com/it/u=4210586523,443489101&fm=253&fmt=auto&app=138&f=JPEG?w=304&h=304",
"https://img2.baidu.com/it/u=2559320899,1546883787&fm=253&fmt=auto&app=138&f=JPEG?w=441&h=499",
@ -54,6 +54,7 @@ class IMUtils {
// channel资料
WKIM.shared.channelManager
.addOnGetChannelListener((channelId, channelType, back) {
print('获取频道资料');
if (channelType == WKChannelType.personal) {
//
//
@ -62,6 +63,8 @@ class IMUtils {
channel.channelName = "【单聊】${channel.channelID}";
var index = channel.channelID.hashCode % imgs.length;
channel.avatar = imgs[index];
channel.remoteExtraMap = {'status': 1, 'notice': 'xx'};
channel.localExtra = {'localStatus': 1, 'localNotice': 'nxx'};
back(channel);
} else if (channelType == WKChannelType.group) {
//
@ -69,6 +72,8 @@ class IMUtils {
channel.channelName = "【群聊】${channel.channelID}";
var index = channel.channelID.hashCode % imgs.length;
channel.avatar = imgs[index];
channel.remoteExtraMap = {'status': 2, 'notice': 'ss'};
channel.localExtra = {'localStatus': 2, 'localNotice': 'nss'};
back(channel);
}
});

View File

@ -26,27 +26,17 @@ class ChannelDB {
insertOrUpdateList(List<WKChannel> list) async {
List<Map<String, dynamic>> addList = [];
List<Map<String, dynamic>> updateList = [];
for (WKChannel channel in list) {
bool bl = await isExist(channel.channelID, channel.channelType);
if (bl) {
updateList.add(getMap(channel));
} else {
if (channel.channelID != '') {
addList.add(getMap(channel));
}
}
if (addList.isNotEmpty || updateList.isNotEmpty) {
if (addList.isNotEmpty) {
WKDBHelper.shared.getDB().transaction((txn) async {
if (addList.isNotEmpty) {
for (Map<String, dynamic> value in addList) {
txn.insert(WKDBConst.tableChannel, value);
}
}
if (updateList.isNotEmpty) {
for (Map<String, dynamic> value in updateList) {
txn.update(WKDBConst.tableChannel, value,
where: "channel_id=? and channel_type=?",
whereArgs: [value['channel_id'], value['channel_type']]);
txn.insert(WKDBConst.tableChannel, value,
conflictAlgorithm: ConflictAlgorithm.replace);
}
}
});
@ -54,12 +44,7 @@ class ChannelDB {
}
saveOrUpdate(WKChannel channel) async {
bool bl = await isExist(channel.channelID, channel.channelType);
if (!bl) {
insert(channel);
} else {
update(channel);
}
insert(channel);
}
insert(WKChannel channel) {

View File

@ -96,24 +96,12 @@ class ChannelMemberDB {
return list;
}
insertOrUpdateList(
List<WKChannelMember> allMemberList, List<WKChannelMember> existList) {
insertList(List<WKChannelMember> allMemberList) {
List<Map<String, Object>> insertCVList = [];
List<Map<String, Object>> updateCVList = [];
for (WKChannelMember channelMember in allMemberList) {
bool isAdd = true;
for (WKChannelMember cm in existList) {
if (channelMember.memberUID == cm.memberUID) {
isAdd = false;
updateCVList.add(getMap(channelMember));
break;
}
}
if (isAdd) {
insertCVList.add(getMap(channelMember));
}
insertCVList.add(getMap(channelMember));
}
if (insertCVList.isNotEmpty || updateCVList.isNotEmpty) {
if (insertCVList.isNotEmpty) {
WKDBHelper.shared.getDB().transaction((txn) async {
if (insertCVList.isNotEmpty) {
for (Map<String, dynamic> value in insertCVList) {
@ -121,18 +109,6 @@ class ChannelMemberDB {
conflictAlgorithm: ConflictAlgorithm.replace);
}
}
if (updateCVList.isNotEmpty) {
for (Map<String, dynamic> value in updateCVList) {
txn.update(WKDBConst.tableChannelMember, value,
where: "channel_id=? and channel_type=? and member_uid=?",
whereArgs: [
value['channel_id'],
value['channel_type'],
value['member_uid']
]);
}
}
});
}
}

View File

@ -87,7 +87,7 @@ class WKChannelMemberManager {
}
//
ChannelMemberDB.shared.insertOrUpdateList(list, existList);
ChannelMemberDB.shared.insertList(list);
if (addList.isNotEmpty) {
setOnNewChannelMember(addList);