fix add pic and attach pic in actions

This commit is contained in:
tiago.kayaya
2022-02-11 15:08:27 +01:00
parent 79bbb9b03d
commit 500349ab97
7 changed files with 39 additions and 78 deletions
@@ -820,7 +820,7 @@ downloadFileMsg(msg) {
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -828,7 +828,7 @@ async openPreview(msg) {
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
+2 -2
View File
@@ -809,7 +809,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -817,7 +817,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
-1
View File
@@ -165,7 +165,6 @@ export class AuthService {
try {
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
message.file.guid = guid.path
alert('uploaded')
await this.storage.set(guid.path, message.file.image_url).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
@@ -833,7 +833,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -841,7 +841,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
@@ -755,8 +755,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
async openPreview(msg) {
console.log(msg);
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -764,7 +765,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
@@ -94,65 +94,26 @@ export class NewPublicationPage implements OnInit {
const capturedImage = await Camera.getPhoto({
quality: 90,
// allowEditing: true,
resultType: CameraResultType.Uri,
resultType: CameraResultType.Base64,
source: CameraSource.Camera
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
this.capturedImageTitle = capturedImage.path;
//console.log(this.capturedImage);
}
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);
});
async laodPicture() {
const capturedImage = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Photos,
quality: 90,
width: 1080,
height: 720,
resultType: CameraResultType.Base64,
source: CameraSource.Photos
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
this.capturedImageTitle = capturedImage.path;
}
/* laodPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
const imageData = await this.fileToBase64Service.convert(file)
this.capturedImage = imageData;
this.capturedImageTitle = file.name
};
} */
runValidation() {
this.validateFrom = true
+1 -1
View File
@@ -6,5 +6,5 @@ export const environment = {
domain: 'gabinetedigital.local',
defaultuser: '',//paulo.pinto paulo.pinto@gabinetedigital.local
defaultuserpwd: '', //tabteste@006,
chatOffline: true
chatOffline: false
};