summaryrefslogtreecommitdiff
path: root/ui/lib/state/remote/channels.svelte.js
blob: 1e40075081e49648dab66164a1d0c4a47c0a24ad (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
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([]);

  add({ at, id, name }) {
    this.all.push(Channel.boot({ at, id, name }));
  }

  remove(id) {
    this.all = this.all.filter((channel) => channel.id !== id);
  }
}