sforkowany z mirror/soapbox
Refactor conditional
rodzic
5f2854571a
commit
cf9156b414
|
@ -108,7 +108,7 @@ const updateNotificationsQueue = (notification: APIEntity, intlMessages: Record<
|
||||||
// Desktop notifications
|
// Desktop notifications
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line compat/compat
|
// eslint-disable-next-line compat/compat
|
||||||
const isNotificationsEnabled = typeof window.Notification !== 'undefined' && Notification.permission === 'granted';
|
const isNotificationsEnabled = window.Notification?.permission === 'granted';
|
||||||
|
|
||||||
if (showAlert && !filtered && isNotificationsEnabled) {
|
if (showAlert && !filtered && isNotificationsEnabled) {
|
||||||
const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username });
|
const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username });
|
||||||
|
|
|
@ -472,7 +472,7 @@ const UI: React.FC = ({ children }) => {
|
||||||
navigator.serviceWorker.addEventListener('message', handleServiceWorkerPostMessage);
|
navigator.serviceWorker.addEventListener('message', handleServiceWorkerPostMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window.Notification !== 'undefined' && Notification.permission === 'default') {
|
if (window.Notification?.permission === 'default') {
|
||||||
window.setTimeout(() => Notification.requestPermission(), 120 * 1000);
|
window.setTimeout(() => Notification.requestPermission(), 120 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue