diff --git a/backend/pubsub.js b/backend/pubsub.js index a50df6cad..12e1726bc 100644 --- a/backend/pubsub.js +++ b/backend/pubsub.js @@ -330,6 +330,9 @@ const publicMethods = { for (const client of to || server.clients) { const msg = typeof message === 'string' ? message : JSON.stringify(message) if (client.endpoint) { + if (msg.length > 1) { + console.error('@@XXX1 posting', typeof message, message) + } postEvent(client, msg).catch(e => { console.error(e, 'Error posting push notification') }) diff --git a/frontend/main.js b/frontend/main.js index 9475b036c..9e80247a1 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -166,6 +166,9 @@ async function startApp () { window.location.reload() // try again, sometimes it fixes it throw e }) + if (typeof Notification === 'function') { + sbp('state/vuex/commit', 'setNotificationEnabled', Notification.permission === 'granted') + } /* TODO: MOVE TO ANOTHER FILE */ sbp('okTurtles.data/set', 'API_URL', self.location.origin) diff --git a/shared/pubsub.js b/shared/pubsub.js index 3aade79d3..da839e236 100644 --- a/shared/pubsub.js +++ b/shared/pubsub.js @@ -95,6 +95,8 @@ export type UnsubMessage = { // ====== Enums ====== // export const NOTIFICATION_TYPE = Object.freeze({ + // used for push notifications in excess of 4 KiB + ABBREVIATED_ENTRY: 'abbreviated_entry', ENTRY: 'entry', KV: 'kv', PING: 'ping',