fix: recorded audio race conditions (#91)
* fix: audio recorder race condition * fix: send audio race condition * fix: streamline audio attachment handling by consolidating removal logic
This commit is contained in:
parent
188119317e
commit
d50f536f79
@ -117,7 +117,6 @@ export default {
|
|||||||
showVariablesMenu: false,
|
showVariablesMenu: false,
|
||||||
newConversationModalActive: false,
|
newConversationModalActive: false,
|
||||||
showArticleSearchPopover: false,
|
showArticleSearchPopover: false,
|
||||||
hasRecordedAudio: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -294,6 +293,9 @@ export default {
|
|||||||
hasAttachments() {
|
hasAttachments() {
|
||||||
return this.attachedFiles.length;
|
return this.attachedFiles.length;
|
||||||
},
|
},
|
||||||
|
hasRecordedAudio() {
|
||||||
|
return this.attachedFiles.some(file => file.isRecordedAudio);
|
||||||
|
},
|
||||||
isRichEditorEnabled() {
|
isRichEditorEnabled() {
|
||||||
return this.isAWebWidgetInbox || this.isAnEmailChannel;
|
return this.isAWebWidgetInbox || this.isAnEmailChannel;
|
||||||
},
|
},
|
||||||
@ -898,7 +900,9 @@ export default {
|
|||||||
},
|
},
|
||||||
onFinishRecorder(file) {
|
onFinishRecorder(file) {
|
||||||
this.recordingAudioState = 'stopped';
|
this.recordingAudioState = 'stopped';
|
||||||
this.hasRecordedAudio = true;
|
|
||||||
|
this.removeRecordedAudio();
|
||||||
|
|
||||||
// Added a new key isRecordedAudio to the file to find it's and recorded audio
|
// Added a new key isRecordedAudio to the file to find it's and recorded audio
|
||||||
// Because to filter and show only non recorded audio and other attachments
|
// Because to filter and show only non recorded audio and other attachments
|
||||||
const autoRecordedFile = {
|
const autoRecordedFile = {
|
||||||
@ -922,6 +926,10 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
attachFile({ blob, file }) {
|
attachFile({ blob, file }) {
|
||||||
|
if (file?.isRecordedAudio) {
|
||||||
|
this.removeRecordedAudio();
|
||||||
|
}
|
||||||
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsDataURL(file.file);
|
reader.readAsDataURL(file.file);
|
||||||
reader.onloadend = () => {
|
reader.onloadend = () => {
|
||||||
@ -1094,8 +1102,10 @@ export default {
|
|||||||
this.recordingAudioDurationText = '00:00';
|
this.recordingAudioDurationText = '00:00';
|
||||||
this.isRecordingAudio = false;
|
this.isRecordingAudio = false;
|
||||||
this.recordingAudioState = '';
|
this.recordingAudioState = '';
|
||||||
this.hasRecordedAudio = false;
|
|
||||||
// Only clear the recorded audio when we click toggle button.
|
// Only clear the recorded audio when we click toggle button.
|
||||||
|
this.removeRecordedAudio();
|
||||||
|
},
|
||||||
|
removeRecordedAudio() {
|
||||||
this.attachedFiles = this.attachedFiles.filter(
|
this.attachedFiles = this.attachedFiles.filter(
|
||||||
file => !file?.isRecordedAudio
|
file => !file?.isRecordedAudio
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user