Skip to content

Commit

Permalink
Merge pull request #739 from webitel/fix/custom-ringtone-validation
Browse files Browse the repository at this point in the history
Fix/custom ringtone validation [WTEL-4814]
  • Loading branch information
dlohvinov authored Aug 5, 2024
2 parents ea672da + 5239e04 commit 36d935f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/modules/settings/components/custom-ringtone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
:autoplay="false"
/>
<wt-button
:disabled="isRingtoneSaved"
@click.prevent="saveRingtone"
>
{{ $t('objects.save') }}
Expand All @@ -47,16 +48,21 @@ export default {
isCustomRingtone: false,
ringtone: {},
options: [],
savedRingtone: null,
}),
computed: {
isRingtoneSelected() {
return this.isCustomRingtone && this.ringtone.name;
},
audioLink() {
return this.isRingtoneSelected
? `${import.meta.env.VITE_RINGTONES_URL}/${this.ringtone.name}`
: '';
},
return this.isRingtoneSelected
? `${import.meta.env.VITE_RINGTONES_URL}/${this.ringtone.name}`
: '';
},
isRingtoneSaved() {
return !this.savedRingtone && !this.ringtone.name // if was chosen default ringtone
|| this.savedRingtone === this.ringtone.name;
}
},
methods: {
selectRingtoneType() {
Expand All @@ -67,13 +73,15 @@ export default {
this.ringtone.name
? localStorage.setItem('settings/ringtone', this.ringtone.name)
: localStorage.removeItem('settings/ringtone');
this.savedRingtone = localStorage.getItem('settings/ringtone');
},
async loadRingtonesOptions() {
this.options = await getRingtonesList();
},
restoreRingtone() {
const ringtoneName = localStorage.getItem('settings/ringtone');
if (ringtoneName) {
this.savedRingtone = ringtoneName;
this.ringtone = this.options.find(item => item.name === ringtoneName);
this.isCustomRingtone = true;
}
Expand Down

0 comments on commit 36d935f

Please sign in to comment.