diff options
Diffstat (limited to 'ui/lib/outbox.svelte.js')
| -rw-r--r-- | ui/lib/outbox.svelte.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ui/lib/outbox.svelte.js b/ui/lib/outbox.svelte.js index fd7fdba..0e4cf29 100644 --- a/ui/lib/outbox.svelte.js +++ b/ui/lib/outbox.svelte.js @@ -1,3 +1,6 @@ +import { DateTime } from 'luxon'; +import * as msg from './state/remote/messages.svelte.js'; + import * as api from './apiServer.js'; import * as md from './markdown.js'; @@ -5,9 +8,21 @@ class PostToChannel { constructor(channel, body) { this.channel = channel; this.body = body; + this.at = DateTime.now(); this.renderedBody = md.render(body); } + toSkeleton(sender) { + return { + id: null, + at: this.at, + channel: this.channel, + sender, + body: this.body, + renderedBody: this.renderedBody + }; + } + async send() { return await api.retry(() => api.postToChannel(this.channel, this.body)); } @@ -35,6 +50,7 @@ class CreateChannel { export class Outbox { pending = $state([]); + messages = $derived(this.pending.filter((operation) => operation instanceof PostToChannel)); static empty() { return new Outbox([]); |
