@@ -19,7 +19,6 @@ import PropTypes from 'prop-types';
19
19
import { _t } from "../../../../../languageHandler" ;
20
20
import { MatrixClientPeg } from "../../../../../MatrixClientPeg" ;
21
21
import AccessibleButton from "../../../elements/AccessibleButton" ;
22
- import Notifier from "../../../../../Notifier" ;
23
22
import SettingsStore from '../../../../../settings/SettingsStore' ;
24
23
import { SettingLevel } from "../../../../../settings/SettingLevel" ;
25
24
import { replaceableComponent } from "../../../../../utils/replaceableComponent" ;
@@ -53,9 +52,9 @@ export default class NotificationsSettingsTab extends React.Component {
53
52
console . log ( soundLibrary ) ;
54
53
const selected = ( soundData === null ) ? "default" : soundData . name ;
55
54
this . setState ( {
56
- currentSound : soundData . name || soundData . url ,
57
- selected : selected ,
58
- soundLibrary : soundLibrary ,
55
+ currentSound : soundData . name || soundData . url ,
56
+ selected : selected ,
57
+ soundLibrary : soundLibrary ,
59
58
} ) ;
60
59
}
61
60
@@ -69,7 +68,7 @@ export default class NotificationsSettingsTab extends React.Component {
69
68
}
70
69
71
70
const file = e . target . files [ 0 ] ;
72
- let soundLibrary = this . state . soundLibrary ;
71
+ const soundLibrary = this . state . soundLibrary ;
73
72
74
73
if ( file . name in soundLibrary ) {
75
74
const QuestionDialog = sdk . getComponent ( 'dialogs.QuestionDialog' ) ;
@@ -87,12 +86,11 @@ export default class NotificationsSettingsTab extends React.Component {
87
86
return ;
88
87
}
89
88
this . _uploadSound ( file ) ;
90
-
91
89
}
92
90
93
91
async _uploadSound ( file ) {
94
-
95
92
let type = file . type ;
93
+
96
94
if ( type === "video/ogg" ) {
97
95
// XXX: I've observed browsers allowing users to pick a audio/ogg files,
98
96
// and then calling it a video/ogg. This is a lame hack, but man browsers
@@ -113,7 +111,7 @@ export default class NotificationsSettingsTab extends React.Component {
113
111
url,
114
112
} ;
115
113
116
- let soundLibrary = this . state . soundLibrary ;
114
+ const soundLibrary = this . state . soundLibrary ;
117
115
soundLibrary [ soundJSON . name ] = soundJSON ;
118
116
119
117
await SettingsStore . setValue (
@@ -125,9 +123,8 @@ export default class NotificationsSettingsTab extends React.Component {
125
123
126
124
this . setState ( {
127
125
soundLibrary : soundLibrary ,
128
- selected : soundJSON . name ,
126
+ selected : soundJSON . name ,
129
127
} ) ;
130
-
131
128
}
132
129
133
130
async _onClickSaveSound ( e ) {
@@ -203,8 +200,9 @@ export default class NotificationsSettingsTab extends React.Component {
203
200
204
201
205
202
render ( ) {
206
-
207
203
const notChanged = this . state . currentSound == this . state . selected && ! this . state . currentSoundReplaced ;
204
+ const soundOptions = Object . keys ( this . state . soundLibrary )
205
+ . map ( ( sound , i ) => < option key = { i } value = { sound } > { sound } </ option > ) ;
208
206
209
207
return (
210
208
< div className = "mx_SettingsTab" >
@@ -224,11 +222,17 @@ export default class NotificationsSettingsTab extends React.Component {
224
222
onChange = { this . _onChangeSelection . bind ( this ) }
225
223
>
226
224
< option key = "default" value = "default" > { _t ( "Default" ) } </ option >
227
- { Object . keys ( this . state . soundLibrary ) . map ( ( sound , i ) => < option key = { i } value = { sound } > { sound } </ option > ) }
225
+ { soundOptions }
228
226
< option key = "uplod" value = "upload" > { _t ( "upload" ) } </ option >
229
227
</ Field >
230
228
< form autoComplete = "off" noValidate = { true } >
231
- < input ref = { this . _soundUpload } className = "mx_NotificationSound_soundUpload" type = "file" onChange = { this . _onSoundUploadChanged . bind ( this ) } accept = "audio/*" />
229
+ < input
230
+ ref = { this . _soundUpload }
231
+ className = "mx_NotificationSound_soundUpload"
232
+ type = "file"
233
+ onChange = { this . _onSoundUploadChanged . bind ( this ) }
234
+ accept = "audio/*"
235
+ />
232
236
</ form >
233
237
234
238
< AccessibleButton className = "mx_NotificationSound_resetSound" disabled = { notChanged } onClick = { this . _onReset . bind ( this ) } kind = "primary" >
0 commit comments