@@ -3,6 +3,7 @@ import React from 'react';
3
3
import useUpdate from 'react-use/lib/useUpdate' ;
4
4
import styled from 'styled-components' ;
5
5
import { SettingsKey } from '../../data/settings-key' ;
6
+ import { isAudioNotificationSupported } from '../../types/Settings' ;
6
7
import { Notifications } from '../../util/notifications' ;
7
8
import { SessionButton , SessionButtonColor , SessionButtonType } from '../basic/SessionButton' ;
8
9
import { SessionRadioGroup } from '../basic/SessionRadioGroup' ;
@@ -30,10 +31,15 @@ export const SessionNotificationGroupSettings = (props: { hasPassword: boolean |
30
31
if ( props . hasPassword === null ) {
31
32
return null ;
32
33
}
33
- const initialItem =
34
+
35
+ const initialNotificationEnabled =
34
36
window . getSettingValue ( SettingsKey . settingsNotification ) || NOTIFICATION . MESSAGE ;
35
37
36
- const notificationsAreEnabled = initialItem && initialItem !== NOTIFICATION . OFF ;
38
+ const initialAudioNotificationEnabled =
39
+ window . getSettingValue ( SettingsKey . settingsAudioNotification ) || false ;
40
+
41
+ const notificationsAreEnabled =
42
+ initialNotificationEnabled && initialNotificationEnabled !== NOTIFICATION . OFF ;
37
43
38
44
const items = [
39
45
{
@@ -58,7 +64,7 @@ export const SessionNotificationGroupSettings = (props: { hasPassword: boolean |
58
64
{
59
65
conversationId : `preview-notification-${ Date . now ( ) } ` ,
60
66
message :
61
- items . find ( m => m . value === initialItem ) ?. label ||
67
+ items . find ( m => m . value === initialNotificationEnabled ) ?. label ||
62
68
window ?. i18n ?.( 'messageBody' ) ||
63
69
'Message body' ,
64
70
title : window . i18n ( 'notificationPreview' ) ,
@@ -83,14 +89,27 @@ export const SessionNotificationGroupSettings = (props: { hasPassword: boolean |
83
89
title = { window . i18n ( 'notificationsSettingsTitle' ) }
84
90
active = { notificationsAreEnabled }
85
91
/>
92
+ { notificationsAreEnabled && isAudioNotificationSupported ( ) && (
93
+ < SessionToggleWithDescription
94
+ onClickToggle = { async ( ) => {
95
+ await window . setSettingValue (
96
+ SettingsKey . settingsAudioNotification ,
97
+ ! initialAudioNotificationEnabled
98
+ ) ;
99
+ forceUpdate ( ) ;
100
+ } }
101
+ title = { window . i18n ( 'audioNotificationsSettingsTitle' ) }
102
+ active = { initialAudioNotificationEnabled }
103
+ />
104
+ ) }
86
105
{ notificationsAreEnabled ? (
87
106
< SessionSettingsItemWrapper
88
107
title = { window . i18n ( 'notificationsSettingsContent' ) }
89
108
description = { window . i18n ( 'notificationSettingsDialog' ) }
90
109
inline = { false }
91
110
>
92
111
< SessionRadioGroup
93
- initialItem = { initialItem }
112
+ initialItem = { initialNotificationEnabled }
94
113
group = { SettingsKey . settingsNotification }
95
114
items = { items }
96
115
onClick = { async ( selectedRadioValue : string ) => {
0 commit comments