fix(notifications): do not support browser notifications for local servers

This commit is contained in:
Gabe Kangas
2023-04-15 20:10:34 -07:00
parent 74bdab81a3
commit dde512fa14
2 changed files with 11 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
export async function saveNotificationRegistration(channel, destination, accessToken) {
console.log('saveNotificationRegistration');
const URL_REGISTER_NOTIFICATION = `/api/notifications/register`;
const options = {
@@ -9,11 +10,7 @@ export async function saveNotificationRegistration(channel, destination, accessT
body: JSON.stringify({ channel, destination }),
};
try {
await fetch(`${URL_REGISTER_NOTIFICATION}?accessToken=${accessToken}`, options);
} catch (e) {
console.error(e);
}
await fetch(`${URL_REGISTER_NOTIFICATION}?accessToken=${accessToken}`, options);
}
export function isPushNotificationSupported() {
@@ -27,6 +24,7 @@ function urlBase64ToUint8Array(base64String: string) {
const rawData = window.atob(base64);
const outputArray = new Uint8Array(rawData.length);
// eslint-disable-next-line no-plusplus
for (let i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i);
}