diff --git a/src/app/features/settings/Settings.tsx b/src/app/features/settings/Settings.tsx index a872f82d..3803a7a1 100644 --- a/src/app/features/settings/Settings.tsx +++ b/src/app/features/settings/Settings.tsx @@ -10,6 +10,7 @@ import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix'; import { useMediaAuthentication } from '../../hooks/useMediaAuthentication'; import { UserAvatar } from '../../components/user-avatar'; import { nameInitials } from '../../utils/common'; +import { Notifications } from './notifications'; enum SettingsPages { GeneralPage, @@ -162,6 +163,9 @@ export function Settings({ requestClose }: SettingsProps) { {activePage === SettingsPages.AccountPage && ( )} + {activePage === SettingsPages.NotificationPage && ( + + )} ); } diff --git a/src/app/features/settings/notifications/Notifications.tsx b/src/app/features/settings/notifications/Notifications.tsx new file mode 100644 index 00000000..3f948b00 --- /dev/null +++ b/src/app/features/settings/notifications/Notifications.tsx @@ -0,0 +1,109 @@ +import React from 'react'; +import { Box, Text, IconButton, Icon, Icons, Scroll, Switch, Button, color } from 'folds'; +import { Page, PageContent, PageHeader } from '../../../components/page'; +import { SequenceCard } from '../../../components/sequence-card'; +import { SequenceCardStyle } from '../styles.css'; +import { SettingTile } from '../../../components/setting-tile'; +import { useSetting } from '../../../state/hooks/settings'; +import { settingsAtom } from '../../../state/settings'; +import { usePermissionState } from '../../../hooks/usePermission'; + +function SystemNotification() { + const notifPermission = usePermissionState( + 'notifications', + window.Notification.permission === 'default' ? 'prompt' : window.Notification.permission + ); + const [showNotifications, setShowNotifications] = useSetting(settingsAtom, 'showNotifications'); + const [isNotificationSounds, setIsNotificationSounds] = useSetting( + settingsAtom, + 'isNotificationSounds' + ); + + const requestNotificationPermission = () => { + window.Notification.requestPermission(); + }; + + return ( + + System + + + Notification permission is blocked. Please allow notification permission from + browser address bar. + + ) : ( + Show desktop notifications when message arrive. + ) + } + after={ + notifPermission === 'prompt' ? ( + + ) : ( + + ) + } + /> + + + } + /> + + + ); +} + +type NotificationsProps = { + requestClose: () => void; +}; +export function Notifications({ requestClose }: NotificationsProps) { + return ( + + + + + + Notifications + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/src/app/features/settings/notifications/index.ts b/src/app/features/settings/notifications/index.ts new file mode 100644 index 00000000..e7825351 --- /dev/null +++ b/src/app/features/settings/notifications/index.ts @@ -0,0 +1 @@ +export * from './Notifications';