diff options
Diffstat (limited to 'ui/lib/state/remote/channels.svelte.js')
| -rw-r--r-- | ui/lib/state/remote/channels.svelte.js | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/ui/lib/state/remote/channels.svelte.js b/ui/lib/state/remote/channels.svelte.js index 64edb09..8b190dd 100644 --- a/ui/lib/state/remote/channels.svelte.js +++ b/ui/lib/state/remote/channels.svelte.js @@ -1,10 +1,26 @@ -import { SvelteMap } from 'svelte/reactivity'; +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(); + all = $state([]); static boot(channels) { - const all = new SvelteMap(channels.map((channel) => [channel.id, channel])); + const all = channels.map((channel) => Channel.boot(channel)); return new Channels({ all }); } @@ -12,8 +28,8 @@ export class Channels { this.all = all; } - add({ id, name }) { - this.all.set(id, { id, name }); + add({ at, id, name }) { + this.all.set(id, Channel.boot({ at, id, name })); } remove(id) { |
