Skip to content

Commit

Permalink
Add notification enabled check to main
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Nov 28, 2024
1 parent 80a6a5e commit 216dc7d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down
3 changes: 3 additions & 0 deletions frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions shared/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 216dc7d

Please sign in to comment.