diff --git a/static/app-strings.json b/static/app-strings.json
index 93ba7bebc..14d957b45 100644
--- a/static/app-strings.json
+++ b/static/app-strings.json
@@ -2200,6 +2200,10 @@
"Dismiss": "Dismiss",
"Heads up: browser notifications are currently blocked in this browser.": "Heads up: browser notifications are currently blocked in this browser.",
"To enable push notifications please configure your browser to allow notifications on odysee.com.": "To enable push notifications please configure your browser to allow notifications on odysee.com.",
- "There was an error enabling browser notifications. Please make sure your browser settings allow you to subscribe to notifications.": "There was an error enabling browser notifications. Please make sure your browser settings allow you to subscribe to notifications.",
+ "Browser notifications aren't supported. Here's a few tips:": "Browser notifications aren't supported. Here's a few tips:",
+ "Notifications aren't available when in incognito or private mode.": "Notifications aren't available when in incognito or private mode.",
+ "On Firefox, notifications won't function if cookies are set to clear on browser close. Please disable or add an exception for Odysee, then refresh.": "On Firefox, notifications won't function if cookies are set to clear on browser close. Please disable or add an exception for Odysee, then refresh.",
+ "For Brave, enable google push notifications in settings.": "For Brave, enable google push notifications in settings.",
+ "Check browser settings to see if notifications are disabled or otherwise restricted.": "Check browser settings to see if notifications are disabled or otherwise restricted.",
"--end--": "--end--"
}
diff --git a/ui/component/settingsRow/view.jsx b/ui/component/settingsRow/view.jsx
index a59b7e52b..4821dc309 100644
--- a/ui/component/settingsRow/view.jsx
+++ b/ui/component/settingsRow/view.jsx
@@ -7,16 +7,17 @@ type Props = {
subtitle?: string,
multirow?: boolean, // Displays the Value widget(s) below the Label instead of on the right.
useVerticalSeparator?: boolean, // Show a separator line between Label and Value. Useful when there are multiple Values.
+ disabled?: boolean,
children?: React$Node,
};
export default function SettingsRow(props: Props) {
- const { title, subtitle, multirow, useVerticalSeparator, children } = props;
-
+ const { title, subtitle, multirow, useVerticalSeparator, disabled, children } = props;
return (
{__("Notifications aren't available when in incognito or private mode.")}
+
+ {__(
+ "On Firefox, notifications won't function if cookies are set to clear on browser close. Please disable or add an exception for Odysee, then refresh."
+ )}
+
+
{__('For Brave, enable google push notifications in settings.')}
+
{__('Check browser settings to see if notifications are disabled or otherwise restricted.')}
+
+
+ );
+};
+
+type ModalProps = {
+ doHideModal: () => void,
+};
+export const BrowserNotificationErrorModal = (props: ModalProps) => {
+ const { doHideModal } = props;
+ return (
+
+
+
+ );
+};
diff --git a/web/component/browserNotificationSettings/use-browser-notifications.js b/web/component/browserNotificationSettings/use-browser-notifications.js
index e51fcb3c0..64cab9dec 100644
--- a/web/component/browserNotificationSettings/use-browser-notifications.js
+++ b/web/component/browserNotificationSettings/use-browser-notifications.js
@@ -1,39 +1,47 @@
// @flow
-import { useEffect, useState, useMemo } from 'react';
-import { pushSubscribe, pushUnsubscribe, pushIsSubscribed } from '$web/src/push-notifications';
-import { isSupported } from 'firebase/messaging';
+import React, { useEffect, useState, useMemo } from 'react';
+import pushNotifications from '$web/src/push-notifications';
+import { BrowserNotificationErrorModal } from '$web/component/browserNotificationHints';
// @todo: Once we are on Redux 7 we should have proper hooks we can use here for store access.
import { store } from '$ui/store';
import { selectUser } from 'redux/selectors/user';
-import { doToast } from 'redux/actions/notifications';
export default () => {
const [pushPermission, setPushPermission] = useState(window.Notification?.permission);
const [subscribed, setSubscribed] = useState(false);
const [pushEnabled, setPushEnabled] = useState(false);
const [pushSupported, setPushSupported] = useState(false);
+ const [encounteredError, setEncounteredError] = useState(false);
const [user] = useState(selectUser(store.getState()));
useEffect(() => {
- pushIsSubscribed(user.id).then((isSubscribed: boolean) => setSubscribed(isSubscribed));
- isSupported().then((supported: boolean) => setPushSupported(supported));
+ setPushSupported(pushNotifications.supported);
+ if (pushNotifications.supported) {
+ pushNotifications.subscribed(user.id).then((isSubscribed: boolean) => setSubscribed(isSubscribed));
+ }
}, [user]);
useMemo(() => setPushEnabled(pushPermission === 'granted' && subscribed), [pushPermission, subscribed]);
const subscribe = async () => {
- if (await pushSubscribe(user.id)) {
- setSubscribed(true);
- setPushPermission(window.Notification?.permission);
- } else {
- showError();
+ setEncounteredError(false);
+ try {
+ if (await pushNotifications.subscribe(user.id)) {
+ setSubscribed(true);
+ setPushPermission(window.Notification?.permission);
+ return true;
+ } else {
+ setEncounteredError(true);
+ }
+ } catch {
+ setEncounteredError(true);
}
};
const unsubscribe = async () => {
- if (await pushUnsubscribe(user.id)) {
+ if (await pushNotifications.unsubscribe(user.id)) {
setSubscribed(false);
}
};
@@ -46,15 +54,8 @@ export default () => {
return window.Notification?.permission !== 'granted' ? subscribe() : null;
};
- const showError = () => {
- store.dispatch(
- doToast({
- isError: true,
- message: __(
- 'There was an error enabling browser notifications. Please make sure your browser settings allow you to subscribe to notifications.'
- ),
- })
- );
+ const pushErrorModal = () => {
+ return <>{encounteredError && setEncounteredError(false)} />}>;
};
return {
@@ -63,5 +64,6 @@ export default () => {
pushPermission,
pushToggle,
pushRequest,
+ pushErrorModal,
};
};
diff --git a/web/component/browserNotificationSettings/view.jsx b/web/component/browserNotificationSettings/view.jsx
index 4e1482db3..85111e8a6 100644
--- a/web/component/browserNotificationSettings/view.jsx
+++ b/web/component/browserNotificationSettings/view.jsx
@@ -1,39 +1,37 @@
// @flow
-import React from 'react';
-import * as ICONS from 'constants/icons';
+import * as React from 'react';
import SettingsRow from 'component/settingsRow';
import { FormField } from 'component/common/form';
import useBrowserNotifications from '$web/component/browserNotificationSettings/use-browser-notifications';
-import 'scss/component/notifications-blocked.scss';
-import Icon from 'component/common/icon';
-
-const BrowserNotificationsBlocked = () => {
- return (
-
-
-
- {__('Heads up: browser notifications are currently blocked in this browser.')}
-
- {__('To enable push notifications please configure your browser to allow notifications on odysee.com.')}
-
-