From 78d901328261d2306cf59c8e83fc217a63aa4a64 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Sun, 26 Oct 2025 16:46:04 -0400 Subject: Add a button to the client to set up a push subscription. Once a user has set up a push subscription, the client will re-establish it as needed whenever possible, falling back to manual intervention only when it is unable to create a push subscription. This change imposes some architectural changes to the client, though they're not huge: the `session` type now includes a body of state (`push`) whose methods also call into the Pilcrow API. Previously, calls to the API were not made within the `session` types, and were instead only made by page and layout code, but orchestrating that for the push subscription lifecycle proved too complex to deal with. This is an experimental alternative, but it might be something we explore further in the future. --- ui/lib/apiServer.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ui/lib/apiServer.js') diff --git a/ui/lib/apiServer.js b/ui/lib/apiServer.js index ac707a5..f55f271 100644 --- a/ui/lib/apiServer.js +++ b/ui/lib/apiServer.js @@ -55,6 +55,10 @@ export async function acceptInvite(inviteId, name, password) { .catch(responseError); } +export async function createPushSubscription(subscription, vapid) { + return apiServer.post('/push/subscribe', { subscription, vapid }).catch(responseError); +} + export function subscribeToEvents(resumePoint) { const eventsUrl = apiServer.getUri({ url: '/events', -- cgit v1.2.3