fetchPinMessage static method
Future<NIMResult<List<ChatMessage> > >
fetchPinMessage(
- String sessionId,
- NIMSessionType sessionType
获取Pin 的消息列表
Implementation
static Future<NIMResult<List<ChatMessage>>> fetchPinMessage(
String sessionId, NIMSessionType sessionType) {
return NimCore.instance.messageService
.queryMessagePinForSession(sessionId, sessionType)
.then((value) async {
if (value.isSuccess && value.data != null) {
var pinList = value.data!;
var uuidList = pinList.map((e) => e.messageUuid!).toList();
var msgRes = await NimCore.instance.messageService
.queryMessageListByUuid(uuidList, sessionId, sessionType);
if (msgRes.isSuccess && msgRes.data != null) {
List<ChatMessage> msgList =
msgRes.data!.map((e) => ChatMessage(e)).toList();
for (var msg in msgList) {
msg.pinOption = pinList
.firstWhereOrNull((pin) => _isSameMessage(msg.nimMessage, pin));
}
return NIMResult(msgRes.code, msgList, msgRes.errorDetails);
} else {
return NIMResult(msgRes.code, null, msgRes.errorDetails);
}
}
return NIMResult(value.code, null, value.errorDetails);
});
}