summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-07-01 14:24:36 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-07-03 22:43:43 -0400
commit8d412732dc094ead3c5cf86c005d187f9624fc65 (patch)
tree321f4ec443a8005c0bf3001c11e68eefe2bb4f48 /ui
parenta15e3d580124f561864c6a39f1e035eb1b3aab13 (diff)
Replace `channel` with `conversation` throughout the API.
This is a **breaking change** for essentially all clients. Thankfully, there's presently just the one, so we don't need to go to much effort to accommoate that; the client is modified in this commit to adapt, users can reload their client, and life will go on.
Diffstat (limited to 'ui')
-rw-r--r--ui/lib/apiServer.js4
-rw-r--r--ui/lib/session.svelte.js10
-rw-r--r--ui/lib/state/remote/messages.svelte.js12
-rw-r--r--ui/lib/state/remote/state.svelte.js18
-rw-r--r--ui/routes/(app)/ch/[channel]/+page.svelte4
5 files changed, 25 insertions, 23 deletions
diff --git a/ui/lib/apiServer.js b/ui/lib/apiServer.js
index 397638c..1bca6f6 100644
--- a/ui/lib/apiServer.js
+++ b/ui/lib/apiServer.js
@@ -28,11 +28,11 @@ export async function changePassword(password, to) {
}
export async function createChannel(name) {
- return await apiServer.post('/channels', { name }).catch(responseError);
+ return await apiServer.post('/conversations', { name }).catch(responseError);
}
export async function postToChannel(channelId, body) {
- return await apiServer.post(`/channels/${channelId}`, { body }).catch(responseError);
+ return await apiServer.post(`/conversations/${channelId}`, { body }).catch(responseError);
}
export async function deleteMessage(messageId) {
diff --git a/ui/lib/session.svelte.js b/ui/lib/session.svelte.js
index 838401c..0c73e00 100644
--- a/ui/lib/session.svelte.js
+++ b/ui/lib/session.svelte.js
@@ -11,7 +11,7 @@ import { DateTime } from 'luxon';
class Channel {
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;
@@ -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;
diff --git a/ui/lib/state/remote/messages.svelte.js b/ui/lib/state/remote/messages.svelte.js
index 1be001b..852f29e 100644
--- a/ui/lib/state/remote/messages.svelte.js
+++ b/ui/lib/state/remote/messages.svelte.js
@@ -2,21 +2,21 @@ import { DateTime } from 'luxon';
import { render } from '$lib/markdown.js';
class Message {
- static boot({ id, at, channel, sender, body }) {
+ static boot({ id, at, conversation, sender, body }) {
return new Message({
id,
at: DateTime.fromISO(at),
- channel,
+ conversation,
sender,
body,
renderedBody: render(body),
});
}
- 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;
@@ -26,8 +26,8 @@ class Message {
export class Messages {
all = $state([]);
- add({ id, at, channel, sender, body }) {
- const message = Message.boot({ id, at, channel, sender, body });
+ add({ id, at, conversation, sender, body }) {
+ const message = Message.boot({ id, at, conversation, sender, body });
this.all.push(message);
}
diff --git a/ui/lib/state/remote/state.svelte.js b/ui/lib/state/remote/state.svelte.js
index fb46489..ffc88c6 100644
--- a/ui/lib/state/remote/state.svelte.js
+++ b/ui/lib/state/remote/state.svelte.js
@@ -30,8 +30,8 @@ export class State {
// Heartbeats are actually completely ignored here. They're handled in `Session`, but not as a
// special case; _any_ event is a heartbeat event.
switch (event.type) {
- case 'channel':
- return this.onChannelEvent(event);
+ case 'conversation':
+ return this.onConversationEvent(event);
case 'user':
return this.onUserEvent(event);
case 'message':
@@ -39,21 +39,21 @@ export class State {
}
}
- onChannelEvent(event) {
+ onConversationEvent(event) {
switch (event.event) {
case 'created':
- return this.onChannelCreated(event);
+ return this.onConversationCreated(event);
case 'deleted':
- return this.onChannelDeleted(event);
+ return this.onConversationDeleted(event);
}
}
- onChannelCreated(event) {
+ onConversationCreated(event) {
const { id, name } = event;
this.channels.add({ id, name });
}
- onChannelDeleted(event) {
+ onConversationDeleted(event) {
const { id } = event;
this.channels.remove(id);
}
@@ -80,8 +80,8 @@ export class State {
}
onMessageSent(event) {
- const { id, at, channel, sender, body } = event;
- this.messages.add({ id, at, channel, sender, body });
+ const { id, at, conversation, sender, body } = event;
+ this.messages.add({ id, at, conversation, sender, body });
}
onMessageDeleted(event) {
diff --git a/ui/routes/(app)/ch/[channel]/+page.svelte b/ui/routes/(app)/ch/[channel]/+page.svelte
index 87918f7..ef000fc 100644
--- a/ui/routes/(app)/ch/[channel]/+page.svelte
+++ b/ui/routes/(app)/ch/[channel]/+page.svelte
@@ -12,7 +12,9 @@
const channelId = $derived(page.params.channel);
const channel = $derived(session.channels.find((channel) => channel.id === channelId));
- const messages = $derived(session.messages.filter((message) => message.channel === channelId));
+ const messages = $derived(
+ session.messages.filter((message) => message.conversation === channelId),
+ );
const unsent = $derived(outbox.messages.filter((message) => message.channel === channelId));
const deleted = $derived(outbox.deleted.map((message) => message.messageId));
const unsentSkeletons = $derived(