summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/lib/apiServer.js47
-rw-r--r--ui/lib/components/NotificationSettings.svelte1
-rw-r--r--ui/lib/state/remote/state.svelte.js2
3 files changed, 30 insertions, 20 deletions
diff --git a/ui/lib/apiServer.js b/ui/lib/apiServer.js
index 63fd8f9..fa9cbff 100644
--- a/ui/lib/apiServer.js
+++ b/ui/lib/apiServer.js
@@ -7,68 +7,75 @@ 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,
- })
+ return apiServer.post(`/invite/${inviteId}`, { name, password })
.catch(responseError);
}
export async function createPushSubscription(data) {
- return await apiServer
- .post("/push", { data })
+ return await apiServer.post("/push", { data })
.catch(responseError);
}
export async function deletePushSubscription(data) {
- return await apiServer
- .delete("/push", { data })
+ return await apiServer.delete("/push", { data })
.catch(responseError);
}
export async function notifyMe() {
- return await apiServer.post('/notifyMe').catch(responseError);
+ // 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);
}
export function subscribeToEvents(resumePoint) {
diff --git a/ui/lib/components/NotificationSettings.svelte b/ui/lib/components/NotificationSettings.svelte
index 8bc9d8b..f4a0e3f 100644
--- a/ui/lib/components/NotificationSettings.svelte
+++ b/ui/lib/components/NotificationSettings.svelte
@@ -8,6 +8,7 @@
function doSubscribe() {
navigator.serviceWorker.ready
.then(async (registration) => {
+ // TODO: Get vapid key from remote.state instead:
const response = await fetch("/api/vapid");
// and if we fail to get it?
const vapidPublicKey = await response.text();
diff --git a/ui/lib/state/remote/state.svelte.js b/ui/lib/state/remote/state.svelte.js
index 3d65e4a..20fdb91 100644
--- a/ui/lib/state/remote/state.svelte.js
+++ b/ui/lib/state/remote/state.svelte.js
@@ -7,6 +7,8 @@ export class State {
users = $state(new Users());
conversations = $state(new Conversations());
messages = $state(new Messages());
+ vapidKey = $state(null);
+ //TODO: on key added, change this and roll push subs
static boot({ currentUser, heartbeat, resumePoint, events }) {
const state = new State({