summaryrefslogtreecommitdiff
path: root/ui/lib/state/remote/channels.svelte.js
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-05-16 20:33:05 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-05-16 20:33:05 -0400
commit4e8cfb5f37b607382fb80e012133dd372aa4ec36 (patch)
tree47bd3baed1aa18d09b67dbdec846b66cab121c55 /ui/lib/state/remote/channels.svelte.js
parent96d363fd9290d43d2e6a11e2e5269fb8ccf6d65d (diff)
parenta38a449ab78a4e8ab56705922f5c13f9365a92a4 (diff)
Merge remote-tracking branch 'codeberg/prop/unread-channels'
Diffstat (limited to 'ui/lib/state/remote/channels.svelte.js')
-rw-r--r--ui/lib/state/remote/channels.svelte.js26
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) {