✨(frontend) introduce a notification settings
I extended Room settings with a new tab, allowing users to toggle the sound notification they want. Their choices will be persisted.
This commit is contained in:
committed by
aleb_the_flash
parent
83914f8307
commit
e0021dbb80
@@ -6,12 +6,14 @@ import { Heading } from 'react-aria-components'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import {
|
import {
|
||||||
RiAccountCircleLine,
|
RiAccountCircleLine,
|
||||||
|
RiNotification3Line,
|
||||||
RiSettings3Line,
|
RiSettings3Line,
|
||||||
RiSpeakerLine,
|
RiSpeakerLine,
|
||||||
} from '@remixicon/react'
|
} from '@remixicon/react'
|
||||||
import { AccountTab } from './tabs/AccountTab'
|
import { AccountTab } from './tabs/AccountTab'
|
||||||
import { GeneralTab } from '@/features/settings/components/tabs/GeneralTab.tsx'
|
import { NotificationsTab } from './tabs/NotificationsTab'
|
||||||
import { AudioTab } from '@/features/settings/components/tabs/AudioTab.tsx'
|
import { GeneralTab } from './tabs/GeneralTab'
|
||||||
|
import { AudioTab } from './tabs/AudioTab'
|
||||||
import { useSize } from '@/features/rooms/livekit/hooks/useResizeObserver'
|
import { useSize } from '@/features/rooms/livekit/hooks/useResizeObserver'
|
||||||
import { useRef } from 'react'
|
import { useRef } from 'react'
|
||||||
|
|
||||||
@@ -81,12 +83,17 @@ export const SettingsDialogExtended = (props: SettingsDialogExtended) => {
|
|||||||
<RiSettings3Line />
|
<RiSettings3Line />
|
||||||
{isWideScreen && t('tabs.general')}
|
{isWideScreen && t('tabs.general')}
|
||||||
</Tab>
|
</Tab>
|
||||||
|
<Tab icon highlight id="4">
|
||||||
|
<RiNotification3Line />
|
||||||
|
{isWideScreen && t('tabs.notifications')}
|
||||||
|
</Tab>
|
||||||
</TabList>
|
</TabList>
|
||||||
</div>
|
</div>
|
||||||
<div className={tabPanelContainerStyle}>
|
<div className={tabPanelContainerStyle}>
|
||||||
<AccountTab id="1" onOpenChange={props.onOpenChange} />
|
<AccountTab id="1" onOpenChange={props.onOpenChange} />
|
||||||
<AudioTab id="2" />
|
<AudioTab id="2" />
|
||||||
<GeneralTab id="3" />
|
<GeneralTab id="3" />
|
||||||
|
<NotificationsTab id="4" />
|
||||||
</div>
|
</div>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { TabPanel, TabPanelProps } from '@/primitives/Tabs'
|
||||||
|
import { H, Switch } from '@/primitives'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useSnapshot } from 'valtio'
|
||||||
|
import { notificationsStore } from '@/stores/notifications'
|
||||||
|
|
||||||
|
export type NotificationsTabProps = Pick<TabPanelProps, 'id'>
|
||||||
|
|
||||||
|
export const NotificationsTab = ({ id }: NotificationsTabProps) => {
|
||||||
|
const { t } = useTranslation('settings', { keyPrefix: 'notifications' })
|
||||||
|
const notificationsSnap = useSnapshot(notificationsStore)
|
||||||
|
return (
|
||||||
|
<TabPanel padding={'md'} flex id={id}>
|
||||||
|
<H lvl={2}>{t('heading')}</H>
|
||||||
|
<ul
|
||||||
|
className={css({
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '1rem',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{Array.from(notificationsSnap.soundNotifications).map(
|
||||||
|
([key, value]) => (
|
||||||
|
<li key={key}>
|
||||||
|
<Switch
|
||||||
|
aria-label={`${t(`actions.${value ? 'disable' : 'enable'}`)} ${t('label')} "${t(`items.${key}`)}"`}
|
||||||
|
isSelected={value}
|
||||||
|
onChange={(v) => {
|
||||||
|
notificationsStore.soundNotifications.set(key, v)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t(`items.${key}`)}
|
||||||
|
</Switch>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
</TabPanel>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -19,6 +19,19 @@
|
|||||||
},
|
},
|
||||||
"permissionsRequired": ""
|
"permissionsRequired": ""
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"heading": "",
|
||||||
|
"label": "",
|
||||||
|
"actions": {
|
||||||
|
"disable": "",
|
||||||
|
"enable": ""
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"participantJoined": "",
|
||||||
|
"handRaised": "",
|
||||||
|
"messageReceived": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
"dialog": {
|
"dialog": {
|
||||||
"heading": ""
|
"heading": ""
|
||||||
},
|
},
|
||||||
@@ -30,6 +43,7 @@
|
|||||||
"tabs": {
|
"tabs": {
|
||||||
"account": "",
|
"account": "",
|
||||||
"audio": "",
|
"audio": "",
|
||||||
"general": ""
|
"general": "",
|
||||||
|
"notifications": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,19 @@
|
|||||||
},
|
},
|
||||||
"permissionsRequired": "Permissions required"
|
"permissionsRequired": "Permissions required"
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"heading": "Sound notifications",
|
||||||
|
"label": "sound notifications for",
|
||||||
|
"actions": {
|
||||||
|
"disable": "Disable",
|
||||||
|
"enable": "Enable"
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"participantJoined": "Participant joined",
|
||||||
|
"handRaised": "Hand raised",
|
||||||
|
"messageReceived": "Message received"
|
||||||
|
}
|
||||||
|
},
|
||||||
"dialog": {
|
"dialog": {
|
||||||
"heading": "Settings"
|
"heading": "Settings"
|
||||||
},
|
},
|
||||||
@@ -30,6 +43,7 @@
|
|||||||
"tabs": {
|
"tabs": {
|
||||||
"account": "Profile",
|
"account": "Profile",
|
||||||
"audio": "Audio",
|
"audio": "Audio",
|
||||||
"general": "General"
|
"general": "General",
|
||||||
|
"notifications": "Notifications"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,19 @@
|
|||||||
},
|
},
|
||||||
"permissionsRequired": "Autorisations nécessaires"
|
"permissionsRequired": "Autorisations nécessaires"
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"heading": "Notifications sonores",
|
||||||
|
"label": "la notification sonore pour",
|
||||||
|
"actions": {
|
||||||
|
"disable": "Désactiver",
|
||||||
|
"enable": "Activer"
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"participantJoined": "Un nouveau participant",
|
||||||
|
"handRaised": "Une main levée",
|
||||||
|
"messageReceived": "Un message reçu"
|
||||||
|
}
|
||||||
|
},
|
||||||
"dialog": {
|
"dialog": {
|
||||||
"heading": "Paramètres"
|
"heading": "Paramètres"
|
||||||
},
|
},
|
||||||
@@ -30,6 +43,7 @@
|
|||||||
"tabs": {
|
"tabs": {
|
||||||
"account": "Profile",
|
"account": "Profile",
|
||||||
"audio": "Audio",
|
"audio": "Audio",
|
||||||
"general": "Général"
|
"general": "Général",
|
||||||
|
"notifications": "Notifications"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user