diff --git a/web/components/modals/BrowserNotifyModal/BrowserNotifyModal.tsx b/web/components/modals/BrowserNotifyModal/BrowserNotifyModal.tsx index db14593b3..90d50f113 100644 --- a/web/components/modals/BrowserNotifyModal/BrowserNotifyModal.tsx +++ b/web/components/modals/BrowserNotifyModal/BrowserNotifyModal.tsx @@ -17,6 +17,10 @@ const NotificationsNotSupported = () => (
Browser notifications are not supported in your browser.
); +const NotificationsNotSupportedLocal = () => ( +
Browser notifications are not supported for local servers.
+); + export type PermissionPopupPreviewProps = { start: () => void; }; @@ -106,6 +110,10 @@ export const BrowserNotifyModal = () => { setBrowserPushPermissionsPending(false); }; + if (window.location.hostname === 'localhost') { + return ; + } + if (!browserPushSupported) { return ; } diff --git a/web/services/notifications-service.ts b/web/services/notifications-service.ts index 58e15bdc5..31513481f 100644 --- a/web/services/notifications-service.ts +++ b/web/services/notifications-service.ts @@ -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); }