mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fixe chat message
This commit is contained in:
@@ -411,7 +411,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
async sendAudio(fileName) {
|
||||
const roomId = this.roomId
|
||||
let audioFile;
|
||||
this.storage.get('recordData').then((recordData) => {
|
||||
this.storage.get('recordData').then(async (recordData) => {
|
||||
|
||||
audioFile = recordData;
|
||||
|
||||
@@ -423,7 +423,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
//Converting base64 to blob
|
||||
const encodedData = btoa(this.audioRecorded);
|
||||
const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
|
||||
const blob = this.fileService.base64toBlob(encodedData, recordData.value.mimeType)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
@@ -439,7 +439,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
"title_link_download": true,
|
||||
"type": "audio"
|
||||
}],
|
||||
temporaryData: formData
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
@@ -451,27 +454,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.ChatSystemService.getDmRoom(this.roomId).sendDeleteRequest(msgId)
|
||||
}
|
||||
|
||||
base64toBlob(base64Data, contentType) {
|
||||
contentType = contentType || '';
|
||||
var sliceSize = 1024;
|
||||
var byteCharacters = atob(base64Data);
|
||||
var bytesLength = byteCharacters.length;
|
||||
var slicesCount = Math.ceil(bytesLength / sliceSize);
|
||||
var byteArrays = new Array(slicesCount);
|
||||
|
||||
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
||||
var begin = sliceIndex * sliceSize;
|
||||
var end = Math.min(begin + sliceSize, bytesLength);
|
||||
|
||||
var bytes = new Array(end - begin);
|
||||
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
|
||||
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
||||
}
|
||||
byteArrays[sliceIndex] = new Uint8Array(bytes);
|
||||
}
|
||||
return new Blob(byteArrays, { type: contentType });
|
||||
}
|
||||
|
||||
|
||||
async openViewDocumentModal(file: any) {
|
||||
let task = {
|
||||
@@ -661,7 +643,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
|
||||
const blob = this.dataURItoBlob('data:image/jpeg;base64,' + file.base64String)
|
||||
const base64 = 'data:image/jpeg;base64,' + file.base64String
|
||||
const blob = this.dataURItoBlob(base64)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
@@ -678,7 +661,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
//"image_url": 'data:image/jpeg;base64,' + file.base64String,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
}],
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
@@ -710,7 +696,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
"image_url": capturedImage,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
}],
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
@@ -778,6 +767,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
//const imageData = await this.fileToBase64Service.convert(file)
|
||||
//
|
||||
|
||||
|
||||
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
|
||||
const blob = await response.blob();
|
||||
|
||||
@@ -795,7 +785,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
//"image_url": 'data:image/jpeg;base64,' + file.base64String,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
}],
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
@@ -814,7 +807,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => {
|
||||
console.error(error);
|
||||
})));
|
||||
const blob = this.base64toBlob(encodedData, file.type)
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
@@ -832,7 +825,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user