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.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/ui/lib/state/remote/channels.svelte.js b/ui/lib/state/remote/channels.svelte.js
new file mode 100644
index 0000000..64edb09
--- /dev/null
+++ b/ui/lib/state/remote/channels.svelte.js
@@ -0,0 +1,22 @@
+import { SvelteMap } from 'svelte/reactivity';
+
+export class Channels {
+ all = $state();
+
+ static boot(channels) {
+ const all = new SvelteMap(channels.map((channel) => [channel.id, channel]));
+ return new Channels({ all });
+ }
+
+ constructor({ all }) {
+ this.all = all;
+ }
+
+ add({ id, name }) {
+ this.all.set(id, { id, name });
+ }
+
+ remove(id) {
+ this.all.delete(id);
+ }
+}