-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmessage.js
More file actions
53 lines (43 loc) · 982 Bytes
/
message.js
File metadata and controls
53 lines (43 loc) · 982 Bytes
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
53
import Base from '../base.js';
import User from './user.js';
export default class Message extends Base {
#user;
#room;
#message;
#deleted = false;
#action;
#rainbow;
constructor(data, channel = data.channel) {
super(data);
this.#user = new User(data.user || data.author);
this.#room = channel;
this.#message = data.chatMessage || data.message;
this.#action = (data.action || data.me) === true;
this.#rainbow = data.rainbow === true;
this.update(data);
}
update(data) {
if (data.deleted !== undefined) this.#deleted = data.deleted === true;
}
get channel() {
return this.#room;
}
get message() {
return this.#message;
}
get action() {
return this.#action;
}
get author() {
return this.#user;
}
get deleted() {
return this.#deleted;
}
get rainbow() {
return this.#rainbow;
}
get element() {
return document.querySelector(`#${this.channel} #message-${this.id}`);
}
}