summaryrefslogtreecommitdiff
path: root/ui/lib/state/remote/channels.svelte.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/lib/state/remote/channels.svelte.js')
-rw-r--r--ui/lib/state/remote/channels.svelte.js23
1 files changed, 20 insertions, 3 deletions
diff --git a/ui/lib/state/remote/channels.svelte.js b/ui/lib/state/remote/channels.svelte.js
index 64edb09..b6da31b 100644
--- a/ui/lib/state/remote/channels.svelte.js
+++ b/ui/lib/state/remote/channels.svelte.js
@@ -1,10 +1,27 @@
+import { DateTime } from 'luxon';
import { SvelteMap } from 'svelte/reactivity';
+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 = new SvelteMap(channels.map((channel) => [channel.id, channel]));
+ const all = new SvelteMap(channels.map((channel) => [channel.id, Channel.boot(channel)]));
return new Channels({ all });
}
@@ -12,8 +29,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) {