Skip to content

Commit

Permalink
Merge pull request #252 from webitel/feature/custom-ringtone
Browse files Browse the repository at this point in the history
feature: changes in notification store module for custom ringtone [WTEL-4348]
  • Loading branch information
Lera24 authored Jul 5, 2024
2 parents 7cd5a40 + 775913f commit 629f260
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webitel/ui-sdk",
"version": "24.6.47",
"version": "24.6.48",
"private": false,
"scripts": {
"dev": "vite",
Expand Down
9 changes: 6 additions & 3 deletions src/modules/Notifications/store/NotificationsStoreModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ const getNotificationSound = (action) => {
case ChatActions.Close:
return new Audio(endChatSound);
case CallActions.Ringing:
const audio = new Audio(ringingSound);
audio.loop = true;
return audio;
// default call ringtone sound
return new Audio(ringingSound);
case CallActions.Hangup:
return new Audio(endCallSound);
default:
Expand Down Expand Up @@ -127,9 +126,13 @@ export default class NotificationsStoreModule extends BaseStoreModule {
return;

const audio = sound instanceof Audio ? sound : new Audio(sound);

audio.addEventListener('ended', () => {
context.dispatch('STOP_SOUND');
}, { once: true });

if (action === CallActions.Ringing) audio.loop = true;

audio.play();
localStorage.setItem('wtIsPlaying', 'true');
context.commit('SET_CURRENTLY_PLAYING', audio);
Expand Down

0 comments on commit 629f260

Please sign in to comment.