mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix upload picture
This commit is contained in:
@@ -462,7 +462,10 @@ export class ChatPage implements OnInit {
|
||||
|
||||
modal.onDidDismiss().then((Data) => {
|
||||
console.log('Data', Data.data)
|
||||
this.openMessagesToStartDirectConversation(Data.data);
|
||||
if(Data.data) {
|
||||
this.openMessagesToStartDirectConversation(Data.data);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -519,7 +522,12 @@ export class ChatPage implements OnInit {
|
||||
},
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss();
|
||||
modal.onDidDismiss().then(e => {
|
||||
this.roomId = null;
|
||||
this.selectedRoomId = null;
|
||||
console.log('RoomSelected', room)
|
||||
this.RoomSelected = null
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1081,6 +1081,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.messages1[this.room.$id].push(Ballon)
|
||||
}
|
||||
|
||||
this.messages1[this.room.$id].push(message)
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 100)
|
||||
|
||||
@@ -33,7 +33,7 @@ import { CameraService } from 'src/app/infra/camera/camera.service'
|
||||
import { FilePickerMobileService } from 'src/app/infra/file-picker/mobile/file-picker-mobile.service'
|
||||
import { FilePickerWebService } from 'src/app/infra/file-picker/web/file-picker-web.service'
|
||||
import { allowedDocExtension } from 'src/app/utils/allowedDocExtension';
|
||||
import { JSFileToDataUrl } from 'src/app/utils/ToBase64';
|
||||
import { createDataURL, JSFileToDataUrl } from 'src/app/utils/ToBase64';
|
||||
import { RoomType } from "src/app/core/chat/entity/group";
|
||||
import { MessageViewModal } from '../../store/model/message';
|
||||
import { ChatPopoverPage } from '../chat-popover/chat-popover.page';
|
||||
@@ -46,6 +46,7 @@ import { RoomViewModel } from '../../store/model/room';
|
||||
import { RoomStore } from '../../store/roomStore'
|
||||
import { GroupContactsPage, IGroupContactsPageOutPutSchema } from '../group-messages/group-contacts/group-contacts.page';
|
||||
import { EditGroupPage } from '../edit-group/edit-group.page';
|
||||
import { imageMimeTypes } from 'src/app/utils/allowedImageExtension';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -134,7 +135,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private file: File,
|
||||
private fileOpener: FileOpener,
|
||||
private fileSystemMobileService: FileSystemMobileService,
|
||||
public RoomStore: RoomStore
|
||||
public RoomStore: RoomStore,
|
||||
) {
|
||||
|
||||
this.room = this.navParams.get('room');
|
||||
@@ -667,43 +668,78 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
async pickPicture() {
|
||||
|
||||
const file = await this.FilePickerService.getPicture({
|
||||
cameraResultType: CameraResultType.Base64
|
||||
const result = await this.FilePickerMobileService.getFile({
|
||||
types: imageMimeTypes,
|
||||
multiple: false,
|
||||
readData: true,
|
||||
})
|
||||
|
||||
if(file.isOk()) {
|
||||
|
||||
var base64 = 'data:image/jpeg;base64,' + file.value.base64String
|
||||
if (file.value.format == "jpeg" || file.value.format == "png" || file.value.format == "gif") {
|
||||
|
||||
const compressedImage = await compressImageBase64(
|
||||
base64,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
)
|
||||
|
||||
if(compressedImage.isOk()) {
|
||||
if(result.isOk()) {
|
||||
const file = result.value.files[0]
|
||||
if(file) {
|
||||
let resultUrl = decodeURIComponent(file.path);
|
||||
const base64 = await this.fileSystemMobileService.readFile({resultUrl})
|
||||
|
||||
if(base64.isOk()) {
|
||||
// console.log('1', base64.value)
|
||||
// console.log('base64.value.data', base64.value.data)
|
||||
// console.log('file', file)
|
||||
// console.log('3',createDataURL(base64.value.data, file.mimeType))
|
||||
|
||||
this.RoomStore.sendMessage('', [{
|
||||
file: compressedImage.value,
|
||||
file: base64.value.data,
|
||||
fileName: "foto",
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Image,
|
||||
mimeType: 'image/'+file.value.format
|
||||
mimeType: file.mimeType
|
||||
}])
|
||||
} else {
|
||||
console.log(base64.error)
|
||||
}
|
||||
} else {
|
||||
console.log('no file')
|
||||
}
|
||||
} else {
|
||||
console.log('error', result.error)
|
||||
}
|
||||
|
||||
} else {
|
||||
if(file.error.type == 'PERMISSION_DENIED') {
|
||||
this.toastService._badRequest("Sem acesso a camera")
|
||||
}
|
||||
Logger.error('failed to pick picture from the device', {
|
||||
error: file.error
|
||||
})
|
||||
}
|
||||
// const file = await this.FilePickerService.getPicture({
|
||||
// cameraResultType: CameraResultType.Base64
|
||||
// })
|
||||
|
||||
// if(file.isOk()) {
|
||||
|
||||
// var base64 = 'data:image/jpeg;base64,' + file.value.base64String
|
||||
// if (file.value.format == "jpeg" || file.value.format == "png" || file.value.format == "gif") {
|
||||
|
||||
// const compressedImage = await compressImageBase64(
|
||||
// base64,
|
||||
// 800, // maxWidth
|
||||
// 800, // maxHeight
|
||||
// 0.9 // quality
|
||||
// )
|
||||
|
||||
// if(compressedImage.isOk()) {
|
||||
|
||||
|
||||
// this.RoomStore.sendMessage('', [{
|
||||
// file: compressedImage.value,
|
||||
// fileName: "foto",
|
||||
// source: MessageAttachmentSource.Device,
|
||||
// fileType: MessageAttachmentFileType.Image,
|
||||
// mimeType: 'image/'+file.value.format
|
||||
// }])
|
||||
// }
|
||||
// }
|
||||
|
||||
// } else {
|
||||
// if(file.error.type == 'PERMISSION_DENIED') {
|
||||
// this.toastService._badRequest("Sem acesso a camera")
|
||||
// }
|
||||
// Logger.error('failed to pick picture from the device', {
|
||||
// error: file.error
|
||||
// })
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ export class RoomInfoPage implements OnInit {
|
||||
this.ChatServiceService.getUserPhoto({wxUserId: member.wxUserId, attachmentId: member.userPhoto}).then((result)=> {
|
||||
|
||||
if(result.isOk()) {
|
||||
console.log('get photo', result.value)
|
||||
this.ObjectURL[member.wxUserId] = 'data:image/jpeg;base64,'+result.value
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user