summaryrefslogtreecommitdiff
path: root/ui/lib/state/remote/conversations.svelte.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/lib/state/remote/conversations.svelte.js')
-rw-r--r--ui/lib/state/remote/conversations.svelte.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/ui/lib/state/remote/conversations.svelte.js b/ui/lib/state/remote/conversations.svelte.js
new file mode 100644
index 0000000..79868f4
--- /dev/null
+++ b/ui/lib/state/remote/conversations.svelte.js
@@ -0,0 +1,29 @@
+import { DateTime } from 'luxon';
+
+class Conversation {
+ static boot({ at, id, name }) {
+ return new Conversation({
+ at: DateTime.fromISO(at),
+ id,
+ name,
+ });
+ }
+
+ constructor({ at, id, name }) {
+ this.at = at;
+ this.id = id;
+ this.name = name;
+ }
+}
+
+export class Conversations {
+ all = $state([]);
+
+ add({ at, id, name }) {
+ this.all.push(Conversation.boot({ at, id, name }));
+ }
+
+ remove(id) {
+ this.all = this.all.filter((conversation) => conversation.id !== id);
+ }
+}