Add render changes

This commit is contained in:
Gigiaj 2025-06-08 20:45:43 -05:00
parent e2fbf9e738
commit a271a5647e

View file

@ -189,20 +189,23 @@ function WebPushNotificationSetting() {
} }
export function SystemNotification() { export function SystemNotification() {
const notifPermission = usePermissionState('notifications', getNotificationState()); const [showInAppNotifs, setShowInAppNotifs] = useSetting(settingsAtom, 'showNotifications');
const [showNotifications, setShowNotifications] = useSetting(settingsAtom, 'showNotifications');
const [isNotificationSounds, setIsNotificationSounds] = useSetting( const [isNotificationSounds, setIsNotificationSounds] = useSetting(
settingsAtom, settingsAtom,
'isNotificationSounds' 'isNotificationSounds'
); );
const requestNotificationPermission = () => {
window.Notification.requestPermission();
};
return ( return (
<Box direction="Column" gap="100"> <Box direction="Column" gap="100">
<Text size="L400">System</Text> <Text size="L400">System & Notifications</Text>
<SequenceCard
className={SequenceCardStyle}
variant="SurfaceVariant"
direction="Column"
gap="400"
>
<WebPushNotificationSetting />
</SequenceCard>
<SequenceCard <SequenceCard
className={SequenceCardStyle} className={SequenceCardStyle}
variant="SurfaceVariant" variant="SurfaceVariant"
@ -210,31 +213,9 @@ export function SystemNotification() {
gap="400" gap="400"
> >
<SettingTile <SettingTile
title="Desktop Notifications" title="In-App Notifications"
description={ description="Show a notification when a message arrives while the app is open (but not focused on the room)."
notifPermission === 'denied' ? ( after={<Switch value={showInAppNotifs} onChange={setShowInAppNotifs} />}
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
{'Notification' in window
? 'Notification permission is blocked. Please allow notification permission from browser address bar.'
: 'Notifications are not supported by the system.'}
</Text>
) : (
<span>Show desktop notifications when message arrive.</span>
)
}
after={
notifPermission === 'prompt' ? (
<Button size="300" radii="300" onClick={requestNotificationPermission}>
<Text size="B300">Enable</Text>
</Button>
) : (
<Switch
disabled={notifPermission !== 'granted'}
value={showNotifications}
onChange={setShowNotifications}
/>
)
}
/> />
</SequenceCard> </SequenceCard>
<SequenceCard <SequenceCard
@ -245,7 +226,7 @@ export function SystemNotification() {
> >
<SettingTile <SettingTile
title="Notification Sound" title="Notification Sound"
description="Play sound when new message arrive." description="Play sound when new message arrives and app is open."
after={<Switch value={isNotificationSounds} onChange={setIsNotificationSounds} />} after={<Switch value={isNotificationSounds} onChange={setIsNotificationSounds} />}
/> />
</SequenceCard> </SequenceCard>