bug send file chat

This commit is contained in:
Eudes Inácio
2022-02-10 19:47:16 +01:00
parent d32cbabac6
commit ae7e14d062
5 changed files with 38 additions and 10 deletions
+15
View File
@@ -2999,6 +2999,21 @@
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/document-viewer": {
"version": "5.36.0",
"resolved": "https://registry.npmjs.org/@ionic-native/document-viewer/-/document-viewer-5.36.0.tgz",
"integrity": "sha512-4AuQ7yDyN4coetNNDDkk5hf9ptoj+FvzBcOPH30ZVNnhlzvqtTT5t4coksDqzUlz5vqJuAGQwawpwqdYdTx0rA==",
"requires": {
"@types/cordova": "^0.0.34"
},
"dependencies": {
"@types/cordova": {
"version": "0.0.34",
"resolved": "https://registry.npmjs.org/@types/cordova/-/cordova-0.0.34.tgz",
"integrity": "sha1-6nrd907Ow9dimCegw54smt3HPQQ="
}
}
},
"@ionic-native/fcm": {
"version": "5.36.0",
"resolved": "https://registry.npmjs.org/@ionic-native/fcm/-/fcm-5.36.0.tgz",
+1
View File
@@ -59,6 +59,7 @@
"@fullcalendar/interaction": "^5.3.0",
"@ionic-native/camera": "^5.31.1",
"@ionic-native/core": "^5.0.7",
"@ionic-native/document-viewer": "^5.36.0",
"@ionic-native/fcm": "^5.36.0",
"@ionic-native/file": "^5.36.0",
"@ionic-native/file-path": "^5.30.0",
@@ -233,7 +233,7 @@ ion-toolbar{
@media only screen and (min-width: 801px) {
@media only screen and (min-width: 701px) {
.content-right{
display: flex !important;
width: 65%;
+4 -4
View File
@@ -120,7 +120,7 @@ export class RoomService {
if(this.isSenderIsNotMe(ChatMessage)) {
this.addMessageDB(ChatMessage)
//this.addMessageDB(ChatMessage)
}
}
@@ -145,7 +145,7 @@ export class RoomService {
}
addMessageDB(ChatMessage) {
/* addMessageDB(ChatMessage) {
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
if(messages==null) messages = []
@@ -154,7 +154,7 @@ export class RoomService {
this.storage.set('chatmsg' + this.id, messages)
})
}
} */
async receiveMessageDelete() {
@@ -231,7 +231,7 @@ export class RoomService {
console.log('offlineChatMessage', offlineChatMessage)
this.addMessageDB(offlineChatMessage)
//this.addMessageDB(offlineChatMessage)
const message: MessageService = this.prepareMessage(offlineChatMessage)
setTimeout(() => {
+17 -5
View File
@@ -33,6 +33,7 @@ import { SearchPage } from 'src/app/pages/search/search.page';
import { ProcessesService } from 'src/app/services/processes.service';
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
import { DocumentViewer, DocumentViewerOptions} from '@ionic-native/document-viewer';
const IMAGE_DIR = 'stored-images';
@Component({
@@ -600,22 +601,26 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
console.log('Add image', file)
const imageData = await this.fileToBase64Service.convert(file)
console.log('Add file', file)
/* const imageData = await this.fileToBase64Service.convert(file).then((filee) => {
console.log('Add file', filee)
}) */
const blob = new Blob([file],{type: file.type})
console.log('Add file', blob)
const formData = new FormData();
formData.append("blobFile", file);
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"type": file.type,
"guid": '',
},
attachments: [{
"title": file.name ,
"name": file.name ,
// "text": "description",
"image_url": imageData, // rocketchat
"image_url": file, // rocketchat
"title_link_download": false,
}],
temporaryData: formData
@@ -747,6 +752,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
pdfPreviwe() {
const options: DocumentViewerOptions = {
title: 'My App'
};
DocumentViewer.viewDocument
}
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {