@chat21/chat21-web-widget 5.1.25-rc1 → 5.1.26-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.ts +16 -3
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +33 -1
- package/src/app/component/message-attachment/message-attachment.component.scss +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
### **Copyrigth**:
|
|
7
7
|
*Tiledesk SRL*
|
|
8
8
|
|
|
9
|
+
# 5.1.26-rc1
|
|
10
|
+
- **bug fixed**: improved audio recording/upload flow by ignoring empty recorder chunks, preserving the recorder MIME type when creating the audio blob/file, and uploading audio directly without Base64 conversion
|
|
11
|
+
|
|
12
|
+
|
|
9
13
|
# 5.1.25-rc1
|
|
10
14
|
- **bug fixed**: attachment buttons in messages now respect the container max width and wrap/break long labels instead of being clipped
|
|
11
15
|
|
package/package.json
CHANGED
|
@@ -38,19 +38,32 @@ export class ConversationAudioRecorderComponent {
|
|
|
38
38
|
this.startTime = Date.now();
|
|
39
39
|
navigator.mediaDevices.getUserMedia({ audio: true })
|
|
40
40
|
.then(stream => {
|
|
41
|
+
|
|
42
|
+
this.audioChunks = [];
|
|
43
|
+
|
|
41
44
|
this.mediaRecorder = new MediaRecorder(stream);
|
|
42
45
|
this.mediaRecorder.start();
|
|
43
46
|
this.isRecording = true;
|
|
44
47
|
this.startRecordingEvent.emit();
|
|
45
48
|
this.mediaRecorder.addEventListener('dataavailable', (event) => {
|
|
46
|
-
|
|
49
|
+
if (event.data && event.data.size > 0) {
|
|
50
|
+
this.audioChunks.push(event.data);
|
|
51
|
+
}
|
|
47
52
|
});
|
|
48
53
|
|
|
49
54
|
this.mediaRecorder.addEventListener('stop', () => {
|
|
50
|
-
|
|
55
|
+
// ✅ MIME REALE del recorder
|
|
56
|
+
const mimeType = this.mediaRecorder.mimeType;
|
|
57
|
+
this.audioBlob = new Blob(this.audioChunks, {
|
|
58
|
+
type: mimeType
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// ⭐ chiude microfono
|
|
62
|
+
stream.getTracks().forEach(track => track.stop());
|
|
63
|
+
|
|
64
|
+
this.audioChunks = [];
|
|
51
65
|
this.rawAudioUrl = URL.createObjectURL(this.audioBlob);
|
|
52
66
|
this.audioUrl = this.sanitizer.bypassSecurityTrustUrl(this.rawAudioUrl);
|
|
53
|
-
this.audioChunks = [];
|
|
54
67
|
this.endRecordingEvent.emit(this.audioBlob);
|
|
55
68
|
});
|
|
56
69
|
})
|
package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts
CHANGED
|
@@ -514,14 +514,46 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
|
|
|
514
514
|
onSendRecording(audioBlob: Blob | null) {
|
|
515
515
|
this.isStartRec = false;
|
|
516
516
|
if (audioBlob) {
|
|
517
|
-
this.
|
|
517
|
+
this.prepareAndUpload(audioBlob);
|
|
518
|
+
// this.convertBlobToBase64(audioBlob);
|
|
518
519
|
this.isStopRec = false;
|
|
519
520
|
} else {
|
|
520
521
|
this.isStopRec = false;
|
|
521
522
|
}
|
|
522
523
|
}
|
|
523
524
|
|
|
525
|
+
prepareAndUpload(audioBlob: Blob) {
|
|
524
526
|
|
|
527
|
+
this.isFilePendingToUpload = true;
|
|
528
|
+
|
|
529
|
+
// ⭐ NON modificare il MIME
|
|
530
|
+
const mimeType = audioBlob.type;
|
|
531
|
+
|
|
532
|
+
const size = audioBlob.size;
|
|
533
|
+
const uid = Date.now().toString(36);
|
|
534
|
+
|
|
535
|
+
// estensione coerente col MIME REALE
|
|
536
|
+
let ext = 'mp3';
|
|
537
|
+
const fileName = `audio-${uid}.${ext}`;
|
|
538
|
+
|
|
539
|
+
const file = new File([audioBlob], fileName, {
|
|
540
|
+
type: mimeType,
|
|
541
|
+
lastModified: Date.now()
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// ✅ metadata SENZA base64
|
|
545
|
+
const metadata = {
|
|
546
|
+
name: fileName,
|
|
547
|
+
type: 'audio/mp3',
|
|
548
|
+
uid: uid,
|
|
549
|
+
size: size
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
this.logger.log('[UPLOAD] metadata:', metadata);
|
|
553
|
+
|
|
554
|
+
// stesso metodo che già usi
|
|
555
|
+
this.uploadSingle(metadata, file, '');
|
|
556
|
+
}
|
|
525
557
|
|
|
526
558
|
// Funzione per convertire Blob in Base64 usando FileReader
|
|
527
559
|
async convertBlobToBase64(audioBlob: Blob) {
|