mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fixe chat message
This commit is contained in:
@@ -114,11 +114,14 @@
|
||||
|
||||
<div *ngIf="!msg.attachments[0].image_url">
|
||||
<ion-item class="add-attachment-bg-color" shape="round" lines="none" type="button">
|
||||
|
||||
<ion-icon *ngIf="msg.attachments[0].type != 'webtrix'" name="document" class="file-icon"></ion-icon>
|
||||
<ion-icon *ngIf="msg.attachments[0].type == 'webtrix'" src="assets/icon/webtrix.svg" class="file-icon"></ion-icon>
|
||||
<ion-label>{{file.title}}</ion-label>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' && msg.attachments[0].type != 'webtrix' " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && msg.attachments[0].type != 'webtrix' " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-label>{{ file.title}}</ion-label>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' && msg.attachments[0].type != 'webtrix' && !( msg.downloadLoader == true || msg.uploadingFile == true ) " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && msg.attachments[0].type != 'webtrix' && !( msg.downloadLoader == true || msg.uploadingFile == true ) " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="( msg.downloadLoader == true || msg.uploadingFile == true )" class="icon-download" src="assets/gif/theme/{{ThemeService.currentTheme}}/Blocks-loader.svg" slot="end"></ion-icon>
|
||||
|
||||
</ion-item>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -401,31 +401,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
})
|
||||
} */
|
||||
|
||||
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 sendAudio(fileName) {
|
||||
const roomId = this.roomId
|
||||
let audioFile;
|
||||
this.storage.get('recordData').then((recordData) => {
|
||||
this.storage.get('recordData').then(async (recordData) => {
|
||||
|
||||
audioFile = recordData;
|
||||
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
||||
@@ -439,7 +418,7 @@ export class MessagesPage implements OnInit, 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);
|
||||
@@ -455,7 +434,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"title_link_download": true,
|
||||
"type": "audio"
|
||||
}],
|
||||
temporaryData: formData
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
@@ -658,14 +640,12 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
|
||||
const blob = this.dataURItoBlob('data:image/jpeg;base64,' + file.base64String)
|
||||
console.log('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);
|
||||
|
||||
// console.log('capturedImage', capturedImage);
|
||||
|
||||
this.ChatSystemService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": "application/img",
|
||||
@@ -676,7 +656,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
@@ -789,7 +773,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"title": file.path,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
}],
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
@@ -813,7 +800,7 @@ export class MessagesPage implements OnInit, 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();
|
||||
@@ -831,7 +818,10 @@ export class MessagesPage implements OnInit, 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