blob: 8b190dddd34b50b9f0f6ed15e3822f2be81e416d (
plain)
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
|
import { DateTime } from 'luxon';
class Channel {
static boot({ at, id, name }) {
return new Channel({
at: DateTime.fromISO(at),
id,
name
});
}
constructor({ at, id, name }) {
this.at = at;
this.id = id;
this.name = name;
}
}
export class Channels {
all = $state([]);
static boot(channels) {
const all = channels.map((channel) => Channel.boot(channel));
return new Channels({ all });
}
constructor({ all }) {
this.all = all;
}
add({ at, id, name }) {
this.all.set(id, Channel.boot({ at, id, name }));
}
remove(id) {
this.all.delete(id);
}
}
|