From f38881f3253b3a128154ffd95655859e3dc629dc Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Sun, 3 Nov 2024 21:43:00 -0500 Subject: Run spaces-style prettier formatting --- ui/app.html | 18 +-- ui/lib/apiServer.js | 148 +++++++++--------- ui/lib/components/ActiveChannel.svelte | 62 ++++---- ui/lib/components/Channel.svelte | 10 +- ui/lib/components/ChannelList.svelte | 14 +- ui/lib/components/CreateChannelForm.svelte | 42 ++--- ui/lib/components/CurrentUser.svelte | 34 ++--- ui/lib/components/Invite.svelte | 10 +- ui/lib/components/Invites.svelte | 28 ++-- ui/lib/components/LogIn.svelte | 68 ++++----- ui/lib/components/Message.svelte | 44 +++--- ui/lib/components/MessageInput.svelte | 60 ++++---- ui/lib/components/MessageRun.svelte | 28 ++-- ui/lib/store/channels.js | 60 ++++---- ui/lib/store/logins.js | 34 ++--- ui/lib/store/messages.js | 64 ++++---- ui/routes/(app)/+layout.svelte | 202 ++++++++++++------------- ui/routes/(app)/ch/[channel]/+page.svelte | 24 +-- ui/routes/(app)/me/+page.svelte | 102 ++++++------- ui/routes/(login)/invite/[invite]/+page.js | 32 ++-- ui/routes/(login)/invite/[invite]/+page.svelte | 52 +++---- ui/routes/(login)/login/+page.svelte | 36 ++--- ui/routes/(login)/setup/+page.svelte | 36 ++--- ui/routes/+layout.svelte | 66 ++++---- 24 files changed, 637 insertions(+), 637 deletions(-) diff --git a/ui/app.html b/ui/app.html index 63eb917..51a6780 100644 --- a/ui/app.html +++ b/ui/app.html @@ -1,12 +1,12 @@ - - - - - %sveltekit.head% - - -
%sveltekit.body%
- + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ diff --git a/ui/lib/apiServer.js b/ui/lib/apiServer.js index e537abc..a6fdaa6 100644 --- a/ui/lib/apiServer.js +++ b/ui/lib/apiServer.js @@ -2,120 +2,120 @@ import axios from 'axios'; import { channelsList, logins, messages } from '$lib/store'; export const apiServer = axios.create({ - baseURL: '/api/', - validateStatus: () => true + baseURL: '/api/', + validateStatus: () => true }); export async function boot() { - return apiServer.get('/boot'); + return apiServer.get('/boot'); } export async function setup(name, password) { - return apiServer.post('/setup', { name, password }); + return apiServer.post('/setup', { name, password }); } export async function logIn(name, password) { - return apiServer.post('/auth/login', { name, password }); + return apiServer.post('/auth/login', { name, password }); } export async function logOut() { - return apiServer.post('/auth/logout', {}); + return apiServer.post('/auth/logout', {}); } export async function changePassword(password, to) { - return apiServer.post('/password', { password, to }); + return apiServer.post('/password', { password, to }); } export async function createChannel(name) { - return apiServer.post('/channels', { name }); + return apiServer.post('/channels', { name }); } export async function postToChannel(channelId, body) { - return apiServer.post(`/channels/${channelId}`, { body }); + return apiServer.post(`/channels/${channelId}`, { body }); } export async function createInvite() { - return apiServer.post(`/invite`, {}); + return apiServer.post(`/invite`, {}); } export async function getInvite(inviteId) { - return apiServer.get(`/invite/${inviteId}`); + return apiServer.get(`/invite/${inviteId}`); } export async function acceptInvite(inviteId, username, password) { - const data = { - name: username, - password - }; - return apiServer.post(`/invite/${inviteId}`, data); + const data = { + name: username, + password + }; + return apiServer.post(`/invite/${inviteId}`, data); } export function subscribeToEvents(resume_point) { - const eventsUrl = new URL('/api/events', window.location); - eventsUrl.searchParams.append('resume_point', resume_point); - const evtSource = new EventSource(eventsUrl.toString()); - // TODO: this should process all incoming events and store them. - // TODO: eventually we'll need to handle expiring old info, so as not to use - // infinite browser memory. - /* - * Known message types as of now: - * - created: a channel is created. - * - action: ignore. - * - message: a message is created. - * - action: display message in channel. - * - message_deleted: a message is deleted. - * - action: replace message with <...>. - * - deleted: a channel is deleted. - * - action: remove channel from sidebar. - */ - evtSource.onmessage = (evt) => { - const data = JSON.parse(evt.data); - - switch (data.type) { - case 'login': - onLoginEvent(data); - break; - case 'channel': - onChannelEvent(data); - break; - case 'message': - onMessageEvent(data); - break; - } - }; - - return evtSource; + const eventsUrl = new URL('/api/events', window.location); + eventsUrl.searchParams.append('resume_point', resume_point); + const evtSource = new EventSource(eventsUrl.toString()); + // TODO: this should process all incoming events and store them. + // TODO: eventually we'll need to handle expiring old info, so as not to use + // infinite browser memory. + /* + * Known message types as of now: + * - created: a channel is created. + * - action: ignore. + * - message: a message is created. + * - action: display message in channel. + * - message_deleted: a message is deleted. + * - action: replace message with <...>. + * - deleted: a channel is deleted. + * - action: remove channel from sidebar. + */ + evtSource.onmessage = (evt) => { + const data = JSON.parse(evt.data); + + switch (data.type) { + case 'login': + onLoginEvent(data); + break; + case 'channel': + onChannelEvent(data); + break; + case 'message': + onMessageEvent(data); + break; + } + }; + + return evtSource; } function onLoginEvent(data) { - switch (data.event) { - case 'created': - logins.update((value) => value.addLogin(data.id, data.name)); - break; - } + switch (data.event) { + case 'created': + logins.update((value) => value.addLogin(data.id, data.name)); + break; + } } function onChannelEvent(data) { - switch (data.event) { - case 'created': - channelsList.update((value) => value.addChannel(data.id, data.name)); - break; - case 'deleted': - channelsList.update((value) => value.deleteChannel(data.id)); - messages.update((value) => value.deleteChannel(data.id)); - break; - } + switch (data.event) { + case 'created': + channelsList.update((value) => value.addChannel(data.id, data.name)); + break; + case 'deleted': + channelsList.update((value) => value.deleteChannel(data.id)); + messages.update((value) => value.deleteChannel(data.id)); + break; + } } function onMessageEvent(data) { - switch (data.event) { - case 'sent': - messages.update((value) => - value.addMessage(data.channel, data.id, data.at, data.sender, data.body) - ); - break; - case 'deleted': - messages.update((value) => value.deleteMessage(data.id)); - break; - } + switch (data.event) { + case 'sent': + messages.update((value) => + value.addMessage(data.channel, data.id, data.at, data.sender, data.body) + ); + break; + case 'deleted': + messages.update((value) => value.deleteMessage(data.id)); + break; + } } diff --git a/ui/lib/components/ActiveChannel.svelte b/ui/lib/components/ActiveChannel.svelte index ac1a0b9..a4ccd24 100644 --- a/ui/lib/components/ActiveChannel.svelte +++ b/ui/lib/components/ActiveChannel.svelte @@ -1,42 +1,42 @@
- {#each chunkBy(messageList, (msg) => msg.sender) as [sender, messages]} -
- -
- {/each} + {#each chunkBy(messageList, (msg) => msg.sender) as [sender, messages]} +
+ +
+ {/each}
diff --git a/ui/lib/components/Channel.svelte b/ui/lib/components/Channel.svelte index fdc5d56..e84c6d0 100644 --- a/ui/lib/components/Channel.svelte +++ b/ui/lib/components/Channel.svelte @@ -1,10 +1,10 @@
  • - - # - {name} - + + # + {name} +
  • diff --git a/ui/lib/components/ChannelList.svelte b/ui/lib/components/ChannelList.svelte index 9d1227e..51dd6cf 100644 --- a/ui/lib/components/ChannelList.svelte +++ b/ui/lib/components/ChannelList.svelte @@ -1,13 +1,13 @@ diff --git a/ui/lib/components/CreateChannelForm.svelte b/ui/lib/components/CreateChannelForm.svelte index ac43925..afa3f78 100644 --- a/ui/lib/components/CreateChannelForm.svelte +++ b/ui/lib/components/CreateChannelForm.svelte @@ -1,30 +1,30 @@
    - - + +
    diff --git a/ui/lib/components/MessageInput.svelte b/ui/lib/components/MessageInput.svelte index 220ed3b..907391c 100644 --- a/ui/lib/components/MessageInput.svelte +++ b/ui/lib/components/MessageInput.svelte @@ -1,40 +1,40 @@
    - - + +
    diff --git a/ui/lib/components/MessageRun.svelte b/ui/lib/components/MessageRun.svelte index 23c2186..b3e3eee 100644 --- a/ui/lib/components/MessageRun.svelte +++ b/ui/lib/components/MessageRun.svelte @@ -1,22 +1,22 @@
    - - @{name}: - - {#each messages as { at, body }} - - {/each} + + @{name}: + + {#each messages as { at, body }} + + {/each}
    diff --git a/ui/lib/store/channels.js b/ui/lib/store/channels.js index b57ca7e..37dc673 100644 --- a/ui/lib/store/channels.js +++ b/ui/lib/store/channels.js @@ -1,36 +1,36 @@ export class Channels { - constructor() { - this.channels = []; - } + constructor() { + this.channels = []; + } - setChannels(channels) { - this.channels = [...channels]; - this.sort(); - return this; - } + setChannels(channels) { + this.channels = [...channels]; + this.sort(); + return this; + } - addChannel(id, name) { - this.channels = [...this.channels, { id, name }]; - this.sort(); - return this; - } + addChannel(id, name) { + this.channels = [...this.channels, { id, name }]; + this.sort(); + return this; + } - deleteChannel(id) { - const channelIndex = this.channels.map((e) => e.id).indexOf(id); - if (channelIndex !== -1) { - this.channels.splice(channelIndex, 1); - } - return this; - } + deleteChannel(id) { + const channelIndex = this.channels.map((e) => e.id).indexOf(id); + if (channelIndex !== -1) { + this.channels.splice(channelIndex, 1); + } + return this; + } - sort() { - this.channels.sort((a, b) => { - if (a.name < b.name) { - return -1; - } else if (a.name > b.name) { - return 1; - } - return 0; - }); - } + sort() { + this.channels.sort((a, b) => { + if (a.name < b.name) { + return -1; + } else if (a.name > b.name) { + return 1; + } + return 0; + }); + } } diff --git a/ui/lib/store/logins.js b/ui/lib/store/logins.js index 5b45206..d449b3a 100644 --- a/ui/lib/store/logins.js +++ b/ui/lib/store/logins.js @@ -1,22 +1,22 @@ export class Logins { - constructor() { - this.logins = {}; - } + constructor() { + this.logins = {}; + } - addLogin(id, name) { - this.logins[id] = name; - return this; - } + addLogin(id, name) { + this.logins[id] = name; + return this; + } - setLogins(logins) { - this.logins = {}; - for (let { id, name } of logins) { - this.addLogin(id, name); - } - return this; - } + setLogins(logins) { + this.logins = {}; + for (let { id, name } of logins) { + this.addLogin(id, name); + } + return this; + } - get(id) { - return this.logins[id]; - } + get(id) { + return this.logins[id]; + } } diff --git a/ui/lib/store/messages.js b/ui/lib/store/messages.js index 884b296..62c567a 100644 --- a/ui/lib/store/messages.js +++ b/ui/lib/store/messages.js @@ -1,40 +1,40 @@ export class Messages { - constructor() { - this.channels = {}; - } + constructor() { + this.channels = {}; + } - inChannel(channel) { - return (this.channels[channel] = this.channels[channel] || []); - } + inChannel(channel) { + return (this.channels[channel] = this.channels[channel] || []); + } - addMessage(channel, id, at, sender, body) { - this.updateChannel(channel, (messages) => [...messages, { id, at, sender, body }]); - return this; - } + addMessage(channel, id, at, sender, body) { + this.updateChannel(channel, (messages) => [...messages, { id, at, sender, body }]); + return this; + } - setMessages(messages) { - this.channels = {}; - for (let { channel, id, at, sender, body } of messages) { - this.inChannel(channel).push({ id, at, sender, body }); - } - return this; - } + setMessages(messages) { + this.channels = {}; + for (let { channel, id, at, sender, body } of messages) { + this.inChannel(channel).push({ id, at, sender, body }); + } + return this; + } - deleteMessage(message) { - for (let channel in this.channels) { - this.updateChannel(channel, (messages) => messages.filter((msg) => msg.id != message)); - } - return this; - } + deleteMessage(message) { + for (let channel in this.channels) { + this.updateChannel(channel, (messages) => messages.filter((msg) => msg.id != message)); + } + return this; + } - deleteChannel(id) { - delete this.channels[id]; - return this; - } + deleteChannel(id) { + delete this.channels[id]; + return this; + } - updateChannel(channel, callback) { - let messages = callback(this.inChannel(channel)); - messages.sort((a, b) => a.at - b.at); - this.channels[channel] = messages; - } + updateChannel(channel, callback) { + let messages = callback(this.inChannel(channel)); + messages.sort((a, b) => a.at - b.at); + this.channels[channel] = messages; + } } diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte index 356a096..94e4509 100644 --- a/ui/routes/(app)/+layout.svelte +++ b/ui/routes/(app)/+layout.svelte @@ -1,122 +1,122 @@ - understory + understory {#if loading} -

    Loading…

    +

    Loading…

    {:else} -
    - -
    - -
    -
    +
    + +
    + +
    +
    {/if} diff --git a/ui/routes/(app)/ch/[channel]/+page.svelte b/ui/routes/(app)/ch/[channel]/+page.svelte index a5836fc..49c1c29 100644 --- a/ui/routes/(app)/ch/[channel]/+page.svelte +++ b/ui/routes/(app)/ch/[channel]/+page.svelte @@ -1,23 +1,23 @@
    - +
    - +
    diff --git a/ui/routes/(app)/me/+page.svelte b/ui/routes/(app)/me/+page.svelte index 4531a91..30da6f0 100644 --- a/ui/routes/(app)/me/+page.svelte +++ b/ui/routes/(app)/me/+page.svelte @@ -1,64 +1,64 @@
    - + - + - + - +
    diff --git a/ui/routes/(login)/invite/[invite]/+page.js b/ui/routes/(login)/invite/[invite]/+page.js index 32c9290..5d526df 100644 --- a/ui/routes/(login)/invite/[invite]/+page.js +++ b/ui/routes/(login)/invite/[invite]/+page.js @@ -1,23 +1,23 @@ import { getInvite } from '$lib/apiServer'; async function loadInvite(invite) { - let response = await getInvite(invite); - switch (response.status) { - case 200: { - let invite = response.data; - return invite; - } - case 404: - return null; - default: - // TODO: display error. - break; - } + let response = await getInvite(invite); + switch (response.status) { + case 200: { + let invite = response.data; + return invite; + } + case 404: + return null; + default: + // TODO: display error. + break; + } } export function load({ params }) { - let { invite } = params; - return { - invite: loadInvite(invite) - }; + let { invite } = params; + return { + invite: loadInvite(invite) + }; } diff --git a/ui/routes/(login)/invite/[invite]/+page.svelte b/ui/routes/(login)/invite/[invite]/+page.svelte index 65f5a97..18bf437 100644 --- a/ui/routes/(login)/invite/[invite]/+page.svelte +++ b/ui/routes/(login)/invite/[invite]/+page.svelte @@ -1,36 +1,36 @@ {#await data.invite} -
    -

    Loading invitation…

    -
    +
    +

    Loading invitation…

    +
    {:then invite} -
    -

    Hi there! {invite.issuer} invites you to the conversation.

    -
    - +
    +

    Hi there! {invite.issuer} invites you to the conversation.

    +
    + {/await} diff --git a/ui/routes/(login)/login/+page.svelte b/ui/routes/(login)/login/+page.svelte index 77c2d62..a1291ea 100644 --- a/ui/routes/(login)/login/+page.svelte +++ b/ui/routes/(login)/login/+page.svelte @@ -1,25 +1,25 @@ diff --git a/ui/routes/(login)/setup/+page.svelte b/ui/routes/(login)/setup/+page.svelte index f95403f..f162ded 100644 --- a/ui/routes/(login)/setup/+page.svelte +++ b/ui/routes/(login)/setup/+page.svelte @@ -1,25 +1,25 @@ diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte index e0355dd..0477195 100644 --- a/ui/routes/+layout.svelte +++ b/ui/routes/+layout.svelte @@ -1,46 +1,46 @@
    -
    - - - - - understory - - {#if $currentUser} - - {/if} - - -
    +
    + + + + + understory + + {#if $currentUser} + + {/if} + + +
    - +
    -- cgit v1.2.3