summaryrefslogtreecommitdiff
path: root/ui/lib/session.svelte.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/lib/session.svelte.js')
-rw-r--r--ui/lib/session.svelte.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/ui/lib/session.svelte.js b/ui/lib/session.svelte.js
index 838401c..4430e8a 100644
--- a/ui/lib/session.svelte.js
+++ b/ui/lib/session.svelte.js
@@ -4,20 +4,20 @@ import { goto } from '$app/navigation';
import * as api from './apiServer.js';
import * as r from './state/remote/state.svelte.js';
-import * as l from './state/local/channels.svelte.js';
+import * as l from './state/local/conversations.svelte.js';
import { Watchdog } from './watchdog.js';
import { DateTime } from 'luxon';
-class Channel {
+class Conversation {
static fromRemote({ at, id, name }, messages, meta) {
const sentAt = messages
- .filter((message) => message.channel === id)
+ .filter((message) => message.conversation === id)
.map((message) => message.at);
const lastEventAt = DateTime.max(at, ...sentAt);
const lastReadAt = meta.get(id)?.lastReadAt;
const hasUnreads = lastReadAt === undefined || lastEventAt > lastReadAt;
- return new Channel({ at, id, name, hasUnreads });
+ return new Conversation({ at, id, name, hasUnreads });
}
constructor({ at, id, name, hasUnreads }) {
@@ -29,21 +29,21 @@ class Channel {
}
class Message {
- static fromRemote({ id, at, channel, sender, body, renderedBody }, users) {
+ static fromRemote({ id, at, conversation, sender, body, renderedBody }, users) {
return new Message({
id,
at,
- channel,
+ conversation,
sender: users.get(sender),
body,
renderedBody,
});
}
- constructor({ id, at, channel, sender, body, renderedBody }) {
+ constructor({ id, at, conversation, sender, body, renderedBody }) {
this.id = id;
this.at = at;
- this.channel = channel;
+ this.conversation = conversation;
this.sender = sender;
this.body = body;
this.renderedBody = renderedBody;
@@ -58,9 +58,9 @@ class Session {
messages = $derived(
this.remote.messages.all.map((message) => Message.fromRemote(message, this.users)),
);
- channels = $derived(
- this.remote.channels.all.map((channel) =>
- Channel.fromRemote(channel, this.messages, this.local.all),
+ conversations = $derived(
+ this.remote.conversations.all.map((conversation) =>
+ Conversation.fromRemote(conversation, this.messages, this.local.all),
),
);
@@ -71,7 +71,7 @@ class Session {
heartbeat,
events,
});
- const local = l.Channels.fromLocalStorage();
+ const local = l.Conversations.fromLocalStorage();
return new Session(remote, local);
}
@@ -109,7 +109,7 @@ class Session {
onMessage(message) {
const event = JSON.parse(message.data);
this.remote.onEvent(event);
- this.local.retainChannels(this.remote.channels.all);
+ this.local.retainConversations(this.remote.conversations.all);
this.watchdog.reset(this.heartbeatMillis());
}