open 3.0
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
@@ -71,26 +73,13 @@ class ConversationManager {
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getMultipleConversation',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// 通过会话id删除指定会话
|
||||
/// [conversationID] 被删除的会话的id
|
||||
Future deleteConversation({
|
||||
required String conversationID,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'deleteConversation',
|
||||
'getMultipleConversation',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
}))
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// 设置会话草稿
|
||||
/// [conversationID] 会话id
|
||||
@@ -124,6 +113,19 @@ class ConversationManager {
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// 置顶会话
|
||||
/// [conversationID] 会话id
|
||||
Future hideConversation({
|
||||
required String conversationID,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'hideConversation',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// 获取未读消息总数
|
||||
/// int.tryParse(count) ?? 0;
|
||||
Future<dynamic> getTotalUnreadMsgCount({
|
||||
@@ -138,29 +140,29 @@ class ConversationManager {
|
||||
/// 查询会话id
|
||||
/// [sourceID] 如果是单聊值传用户ID,如果是群聊值传组ID
|
||||
/// [sessionType] 参考[ConversationType]
|
||||
Future<dynamic> getConversationIDBySessionType({
|
||||
required String sourceID,
|
||||
required int sessionType,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'getConversationIDBySessionType',
|
||||
_buildParam({
|
||||
"sourceID": sourceID,
|
||||
"sessionType": sessionType,
|
||||
}));
|
||||
// Future<dynamic> getConversationIDBySessionType({
|
||||
// required String sourceID,
|
||||
// required int sessionType,
|
||||
// }) =>
|
||||
// _channel.invokeMethod(
|
||||
// 'getConversationIDBySessionType',
|
||||
// _buildParam({
|
||||
// "sourceID": sourceID,
|
||||
// "sessionType": sessionType,
|
||||
// }));
|
||||
|
||||
/// 消息免打扰设置
|
||||
/// [conversationIDList] 会话id列表
|
||||
/// [conversationID] 会话id
|
||||
/// [status] 0:正常;1:不接受消息;2:接受在线消息不接受离线消息;
|
||||
Future<dynamic> setConversationRecvMessageOpt({
|
||||
required List<String> conversationIDList,
|
||||
required String conversationID,
|
||||
required int status,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setConversationRecvMessageOpt',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"conversationID": conversationID,
|
||||
"status": status,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
@@ -184,13 +186,13 @@ class ConversationManager {
|
||||
/// 阅后即焚
|
||||
/// [conversationID] 会话id
|
||||
/// [isPrivate] true:开启,false:关闭
|
||||
Future<dynamic> setOneConversationPrivateChat({
|
||||
Future<dynamic> setConversationPrivateChat({
|
||||
required String conversationID,
|
||||
required bool isPrivate,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setOneConversationPrivateChat',
|
||||
'setConversationPrivateChat',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"isPrivate": isPrivate,
|
||||
@@ -199,12 +201,25 @@ class ConversationManager {
|
||||
|
||||
/// 删除本地以及服务器的会话
|
||||
/// [conversationID] 会话ID
|
||||
Future<dynamic> deleteConversationFromLocalAndSvr({
|
||||
Future<dynamic> deleteConversationAndDeleteAllMsg({
|
||||
required String conversationID,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'deleteConversationFromLocalAndSvr',
|
||||
'deleteConversationAndDeleteAllMsg',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// 清空会话里的消息
|
||||
/// [conversationID] 会话ID
|
||||
Future<dynamic> clearConversationAndDeleteAllMsg({
|
||||
required String conversationID,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'clearConversationAndDeleteAllMsg',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
@@ -234,8 +249,14 @@ class ConversationManager {
|
||||
}));
|
||||
|
||||
/// 查询@所有人标识
|
||||
Future<dynamic> getAtAllTag() =>
|
||||
_channel.invokeMethod('getAtAllTag', _buildParam({}));
|
||||
Future<dynamic> getAtAllTag({
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'getAtAllTag',
|
||||
_buildParam({
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// 查询@所有人标识
|
||||
String get atAllTag => 'atAllTag';
|
||||
@@ -256,19 +277,33 @@ class ConversationManager {
|
||||
/// 设置阅后即焚时长
|
||||
/// [conversationID] 会话id
|
||||
/// [burnDuration] 时长s,默认30s
|
||||
Future<dynamic> setOneConversationBurnDuration({
|
||||
Future<dynamic> setConversationBurnDuration({
|
||||
required String conversationID,
|
||||
int burnDuration = 30,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setOneConversationBurnDuration',
|
||||
'setConversationBurnDuration',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"burnDuration": burnDuration,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// 标记消息已读
|
||||
/// [conversationID] 会话ID
|
||||
/// [messageIDList] 被标记的消息clientMsgID
|
||||
Future markConversationMessageAsRead({
|
||||
required String conversationID,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'markConversationMessageAsRead',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// 会话列表自定义排序规则。
|
||||
List<ConversationInfo> simpleSort(List<ConversationInfo> list) => list
|
||||
..sort((a, b) {
|
||||
@@ -279,23 +314,24 @@ class ConversationManager {
|
||||
: a.latestMsgSendTime!;
|
||||
int bCompare = b.draftTextTime! > b.latestMsgSendTime!
|
||||
? b.draftTextTime!
|
||||
: b.latestMsgSendTime!;
|
||||
if (aCompare > bCompare) {
|
||||
return -1;
|
||||
} else if (aCompare < bCompare) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (a.isPinned == true && b.isPinned != true) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
: b.latestMsgSendTime!;
|
||||
if (aCompare > bCompare) {
|
||||
return -1;
|
||||
} else if (aCompare < bCompare) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (a.isPinned == true && b.isPinned != true) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "conversationManager";
|
||||
log('param: $param');
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user