-
Notifications
You must be signed in to change notification settings - Fork 8
/
IMConversationDelegate.ts
52 lines (51 loc) · 1.91 KB
/
IMConversationDelegate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { ChatManager, IMConstant } from 'react-native-im-easemob';
import { Delegate, Typings } from '../../standard';
export default function () {
Delegate.im.conversation.loadList = () => {
return ChatManager.getAllConversations()
.then((result: Typings.Message.Origin) => {
result = result.map((item) => ({
...item,
imId: item.conversationId,
chatType: item.type,
}));
return result;
});
};
Delegate.im.conversation.loadItem = (imId, chatType, autoCreate) => {
return ChatManager.getConversation(imId, chatType, autoCreate)
.then((result) => {
return {
...result,
imId: result.conversationId,
chatType: result.type,
};
});
};
Delegate.im.conversation.deleteOne = (imId) => {
return ChatManager.deleteConversation(imId);
};
// TODO updateConfig
Delegate.im.conversation.markAllRead = (imId, chatType) => {
return ChatManager.markAllMessagesAsRead(imId, chatType);
};
// TODO markLatestUnread
Delegate.im.conversation.loadMessage = (params) => {
const {imId, chatType, lastMessage, count} = params;
return ChatManager.loadMessages(
imId,
chatType,
lastMessage ? lastMessage.messageId : undefined,
count,
IMConstant.MessageSearchDirection.up
);
};
Delegate.im.conversation.deleteMessage = (params) => {
const {imId, chatType, message: {messageId}} = params;
return ChatManager.deleteMessage(imId, chatType, messageId);
};
Delegate.im.conversation.recallMessage = (params) => {
const {imId, chatType, message: {messageId}} = params;
return ChatManager.recallMessage(imId, chatType, messageId);
};
}