-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathConversation.js
More file actions
executable file
·47 lines (41 loc) · 1.24 KB
/
Conversation.js
File metadata and controls
executable file
·47 lines (41 loc) · 1.24 KB
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
import User from './User';
import Message from './Message';
class Conversation {
id: string;
name: string;
isGroup: boolean;
updatedAt: number;
creator: string;
created: number;
unreadCount: number;
participants: Array<User>;
lastMessage: Message;
pinMsgId: string;
constructor(props) {
this.id = props.id;
this.name = props.name;
this.isGroup = props.isGroup;
this.updatedAt = props.updatedAt;
this.creator = props.creator;
this.created = props.created;
this.unreadCount = props.unreadCount;
let parts = [];
props.participants.map(part => {
let user = new User(part);
parts.push(user);
});
this.participants = parts;
this.lastMessage = new Message(props);
this.lastMessage.localId = null;
this.lastMessage.id = props.lastMsgId;
this.lastMessage.conversationId = props.id;
this.lastMessage.sender = props.lastMsgSender;
this.lastMessage.createdAt = props.lastMsgCreatedAt;
this.lastMessage.state = props.lastMsgState;
this.lastMessage.sequence = props.lastMsgSeq;
this.lastMessage.type = props.lastMsgType;
this.lastMessage.content = props.text;
this.pinMsgId = props.pinMsgId != null ? props.pinMsgId : null;
}
}
export default Conversation;