@@ -193,22 +193,32 @@ class NotificationSoundService {
193193
194194 public async playNotificationSound ( type : NotificationType ) : Promise < void > {
195195 try {
196+ // Ensure audio is initialized before accessing sound properties
197+ await this . initializeAudio ( ) ;
198+
199+ // Capture sound properties into local variables after initialization
200+ const callSound = this . callSound ;
201+ const messageSound = this . messageSound ;
202+ const chatSound = this . chatSound ;
203+ const groupChatSound = this . groupChatSound ;
204+ const defaultSound = this . defaultSound ;
205+
196206 switch ( type ) {
197207 case 'call' :
198- await this . playSound ( this . callSound , 'call' ) ;
208+ await this . playSound ( callSound , 'call' ) ;
199209 break ;
200210 case 'message' :
201- await this . playSound ( this . messageSound , 'message' ) ;
211+ await this . playSound ( messageSound , 'message' ) ;
202212 break ;
203213 case 'chat' :
204- await this . playSound ( this . chatSound , 'chat' ) ;
214+ await this . playSound ( chatSound , 'chat' ) ;
205215 break ;
206216 case 'group-chat' :
207- await this . playSound ( this . groupChatSound , 'group-chat' ) ;
217+ await this . playSound ( groupChatSound , 'group-chat' ) ;
208218 break ;
209219 case 'unknown' :
210220 default :
211- await this . playSound ( this . defaultSound , 'default' ) ;
221+ await this . playSound ( defaultSound , 'default' ) ;
212222 break ;
213223 }
214224 } catch ( error ) {
0 commit comments