diff options
| author | Kit La Touche <kit@transneptune.net> | 2025-09-07 22:19:30 -0400 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2025-09-07 22:19:30 -0400 |
| commit | 9ca03b7044b820a1fe4b6ab8fc690fb6c5312c73 (patch) | |
| tree | bbc0b6dbdb4f01c53b8785d677bf2f090952ebe7 | |
| parent | a82b5271fee07ea1b023596eb94ac035a4983cd8 (diff) | |
Reformat things
| -rw-r--r-- | ui/lib/apiServer.js | 42 | ||||
| -rw-r--r-- | ui/lib/components/NotificationSettings.svelte | 77 | ||||
| -rw-r--r-- | ui/lib/components/Toggle.svelte | 4 | ||||
| -rw-r--r-- | ui/routes/+layout.svelte | 2 | ||||
| -rw-r--r-- | ui/service-worker.js | 4 | ||||
| -rw-r--r-- | ui/styles/toggles.css | 2 |
6 files changed, 55 insertions, 76 deletions
diff --git a/ui/lib/apiServer.js b/ui/lib/apiServer.js index fa9cbff..295c99a 100644 --- a/ui/lib/apiServer.js +++ b/ui/lib/apiServer.js @@ -7,75 +7,61 @@ export const apiServer = axios.create({ }); export async function boot() { - return apiServer.get('/boot') - .catch(responseError); + return apiServer.get('/boot').catch(responseError); } export async function setup(name, password) { - return await apiServer.post('/setup', { name, password }) - .catch(responseError); + return await apiServer.post('/setup', { name, password }).catch(responseError); } export async function logIn(name, password) { - return await apiServer.post('/auth/login', { name, password }) - .catch(responseError); + return await apiServer.post('/auth/login', { name, password }).catch(responseError); } export async function logOut() { - return await apiServer.post('/auth/logout', {}) - .catch(responseError); + return await apiServer.post('/auth/logout', {}).catch(responseError); } export async function changePassword(password, to) { - return await apiServer.post('/password', { password, to }) - .catch(responseError); + return await apiServer.post('/password', { password, to }).catch(responseError); } export async function createConversation(name) { - return await apiServer.post('/conversations', { name }) - .catch(responseError); + return await apiServer.post('/conversations', { name }).catch(responseError); } export async function sendToConversation(conversationId, body) { - return await apiServer.post(`/conversations/${conversationId}`, { body }) - .catch(responseError); + return await apiServer.post(`/conversations/${conversationId}`, { body }).catch(responseError); } export async function deleteMessage(messageId) { - return await apiServer.delete(`/messages/${messageId}`, {}) - .catch(responseError); + return await apiServer.delete(`/messages/${messageId}`, {}).catch(responseError); } export async function createInvite() { - return await apiServer.post(`/invite`, {}) - .catch(responseError); + return await apiServer.post(`/invite`, {}).catch(responseError); } export async function getInvite(inviteId) { - return await apiServer.get(`/invite/${inviteId}`) - .catch(responseError); + return await apiServer.get(`/invite/${inviteId}`).catch(responseError); } export async function acceptInvite(inviteId, name, password) { - return apiServer.post(`/invite/${inviteId}`, { name, password }) - .catch(responseError); + return apiServer.post(`/invite/${inviteId}`, { name, password }).catch(responseError); } export async function createPushSubscription(data) { - return await apiServer.post("/push", { data }) - .catch(responseError); + return await apiServer.post('/push', { data }).catch(responseError); } export async function deletePushSubscription(data) { - return await apiServer.delete("/push", { data }) - .catch(responseError); + return await apiServer.delete('/push', { data }).catch(responseError); } export async function notifyMe() { // TODO: this is the big "missing on the server" endpoint we need to make a // minimal notifications setup. - return await apiServer.post('/notifyMe') - .catch(responseError); + return await apiServer.post('/notifyMe').catch(responseError); } export function subscribeToEvents(resumePoint) { diff --git a/ui/lib/components/NotificationSettings.svelte b/ui/lib/components/NotificationSettings.svelte index f4a0e3f..94acb37 100644 --- a/ui/lib/components/NotificationSettings.svelte +++ b/ui/lib/components/NotificationSettings.svelte @@ -1,5 +1,5 @@ <script> - import { onMount } from "svelte"; + import { onMount } from 'svelte'; import * as api from '$lib/apiServer.js'; import Toggle from '$lib/components/Toggle.svelte'; @@ -9,15 +9,16 @@ navigator.serviceWorker.ready .then(async (registration) => { // TODO: Get vapid key from remote.state instead: - const response = await fetch("/api/vapid"); + const response = await fetch('/api/vapid'); // and if we fail to get it? const vapidPublicKey = await response.text(); const convertedVapidKey = vapidPublicKey; return registration.pushManager.subscribe({ userVisibleOnly: true, - applicationServerKey: convertedVapidKey + applicationServerKey: convertedVapidKey, }); - }).then((subscription) => { + }) + .then((subscription) => { const subJson = subscription.toJSON(); subscriptionJson = { endpoint: subJson.endpoint, @@ -32,13 +33,13 @@ navigator.serviceWorker.ready .then((registration) => { return registration.pushManager.getSubscription(); - }).then((subscription) => { + }) + .then((subscription) => { const { endpoint } = subscription.toJSON(); - return subscription.unsubscribe() - .then(() => { - apiServer.deletePushSubscription({ endpoint }); - subscriptionJson = null; - }); + return subscription.unsubscribe().then(() => { + apiServer.deletePushSubscription({ endpoint }); + subscriptionJson = null; + }); }); } @@ -55,13 +56,15 @@ } onMount(() => { - navigator.serviceWorker.ready.then((registration) => { - return registration.pushManager.getSubscription(); - }).then((subscription) => { - if (subscription) { - subscriptionJson = JSON.parse(JSON.stringify(subscription)); - } - }); + navigator.serviceWorker.ready + .then((registration) => { + return registration.pushManager.getSubscription(); + }) + .then((subscription) => { + if (subscription) { + subscriptionJson = JSON.parse(JSON.stringify(subscription)); + } + }); }); </script> @@ -82,41 +85,31 @@ {/if} </button> -<button class="btn" onclick={testNotifications}> - Test notifications -</button> +<button class="btn" onclick={testNotifications}> Test notifications </button> <h2>Notify me when:</h2> <p>These are currently unimplemented.</p> +<Toggle name="channel_created" text="A new channel is created" onclick={async () => {}} /> +<Toggle name="message_arrives" text="A new message arrives in a channel" onclick={async () => {}} /> <Toggle - name="channel_created" - text="A new channel is created" - onclick={async () => {}} -/> -<Toggle - name="message_arrives" - text="A new message arrives in a channel" - onclick={async () => {}} -/> -<Toggle - name="message_arrives_username" - text="A new message containing your username arrives in a channel" - onclick={async () => {}} + name="message_arrives_username" + text="A new message containing your username arrives in a channel" + onclick={async () => {}} /> <Toggle - name="message_arrives_keyword" - text="A new message containing a keyword you have configured arrives in a channel" - onclick={async () => {}} + name="message_arrives_keyword" + text="A new message containing a keyword you have configured arrives in a channel" + onclick={async () => {}} /> <Toggle - name="own_message_stitched" - text="A message you wrote is stitched" - onclick={async () => {}} + name="own_message_stitched" + text="A message you wrote is stitched" + onclick={async () => {}} /> <Toggle - name="flagged_message_stitched" - text="A message you have flagged is stitched" - onclick={async () => {}} + name="flagged_message_stitched" + text="A message you have flagged is stitched" + onclick={async () => {}} /> diff --git a/ui/lib/components/Toggle.svelte b/ui/lib/components/Toggle.svelte index 7e71b5a..e880d37 100644 --- a/ui/lib/components/Toggle.svelte +++ b/ui/lib/components/Toggle.svelte @@ -4,8 +4,8 @@ <label> <div class="toggle"> - <input type="checkbox" name={name} onclick={onclick}/> + <input type="checkbox" {name} {onclick} /> <span class="slider"></span> </div> - { text } + {text} </label> diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte index 8412fbc..83a9ef7 100644 --- a/ui/routes/+layout.svelte +++ b/ui/routes/+layout.svelte @@ -1,5 +1,5 @@ <script> - import { setContext } from "svelte"; + import { setContext } from 'svelte'; import { onNavigate } from '$app/navigation'; import { page } from '$app/state'; import '../app.css'; diff --git a/ui/service-worker.js b/ui/service-worker.js index a88c5a2..63b307a 100644 --- a/ui/service-worker.js +++ b/ui/service-worker.js @@ -59,7 +59,7 @@ self.addEventListener('push', (event) => { event.waitUntil( // How do we control the action you get when you click the notification? self.registration.showNotification(payload.title, { - body: payload.body - }) + body: payload.body, + }), ); }); diff --git a/ui/styles/toggles.css b/ui/styles/toggles.css index c51d34a..efa0cc0 100644 --- a/ui/styles/toggles.css +++ b/ui/styles/toggles.css @@ -25,7 +25,7 @@ .slider:before { position: absolute; - content: ""; + content: ''; height: 1rem; width: 1rem; background-color: #fff; |
