Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions plugins/notification-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ function addWorkerListener (): void {

export function pushAvailable (): boolean {
if (isDesktopClient()) return false
const publicKey = getMetadata(notification.metadata.PushPublicKey)
const publicKey = getPushPublicKey()
return (
'serviceWorker' in navigator &&
'PushManager' in window &&
Expand All @@ -747,7 +747,7 @@ export async function subscribePush (): Promise<boolean> {
return false
}
const client = getClient()
const publicKey = getMetadata(notification.metadata.PushPublicKey)
const publicKey = getPushPublicKey()
if ('serviceWorker' in navigator && 'PushManager' in window && publicKey !== undefined) {
try {
const loc = getCurrentLocation()
Expand Down Expand Up @@ -802,6 +802,12 @@ export async function subscribePush (): Promise<boolean> {
return false
}

function getPushPublicKey (): string | undefined {
const publicKey = getMetadata(notification.metadata.PushPublicKey)
if (publicKey === undefined) return undefined
return publicKey.trim() !== '' ? publicKey : undefined
}

async function cleanTag (_id: Ref<Doc>): Promise<void> {
const client = getClient()
const notifications = await client.findAll(notification.class.BrowserNotification, {
Expand Down
Loading