reconnect rocketchat socket

This commit is contained in:
Eudes Inácio
2023-09-14 11:58:24 +01:00
parent 9cc97dfc0f
commit 540750e0e9
10 changed files with 193 additions and 80 deletions
@@ -23,7 +23,7 @@ export class EditProfilePage implements OnInit {
SessionStore = SessionStore
production = environment.production
environment = environment
capturedImage = '';
capturedImage: any;
capturedImageTitle = '';
profilePicture = "";
@@ -39,7 +39,8 @@ export class EditProfilePage implements OnInit {
) { }
ngOnInit() {
this.getProfilpictureFromStorage()
this.getProfilpictureFromStorage();
}
getProfilpictureFromStorage() {
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
@@ -49,15 +50,15 @@ export class EditProfilePage implements OnInit {
this.profilePicture = "";
})
}
getProfilpicture(guid) {
/* getProfilpicture(guid) {
console.log('Get picture ', guid.path)
this.attachmentService.downloadFile(guid.path).subscribe(async (picture: any) => {
this.attachmentService.getUserProfilePhoto().subscribe(async (picture: any) => {
let downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(picture.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('Get picture ', downloadFile)
this.storageService.store(this.SessionStore.user.RoleID.toString()+"guid", guid.path)
this.storageService.store(this.SessionStore.user.RoleID.toString(), downloadFile).then((value) => {
console.log('Get picture ', picture)
this.storageService.store(this.SessionStore.user.RoleID.toString() + "guid", guid.path)
this.storageService.store(this.SessionStore.user.RoleID.toString(), picture).then((value) => {
this.profilePicture = picture
this.SessionStore.user.UserPhoto = picture;
console.log('picture saved')
@@ -69,7 +70,7 @@ export class EditProfilePage implements OnInit {
console.log('Error get profile picture: ', error)
}))
}
} */
close() {
this.modalController.dismiss();
@@ -177,20 +178,27 @@ export class EditProfilePage implements OnInit {
source: CameraSource.Camera
});
this.capturedImageTitle = SessionStore.user.Profile;
this.capturedImage = 'data:image/jpeg;base64,' + capturedImage.base64String;
this.capturedImage = capturedImage.base64String;
var object = JSON.stringify({
"ImageBase64": this.capturedImage
}
)
console.log('ATTACHME ', object)
const blob = this.dataURItoBlob(this.capturedImage)
const formData = new FormData();
formData.append("blobFile", blob);
this.attachmentService.uploadFile(formData).subscribe((guid) => {
this.attachmentService.addUserProfilePhoto(object).subscribe((guid) => {
console.log('GUID ', guid)
console.log(this.SessionStore.user.RoleID.toString())
this.getProfilpicture(guid);
this.storageService.store(this.SessionStore.user.RoleID.toString(), this.capturedImage).then((value) => {
this.profilePicture = 'data:image/jpeg;base64,' +this.capturedImage;
console.log('picture saved')
}).catch((error) => {
console.log('picture not saved')
});
/* this.getProfilpicture(guid); */
}, ((error) => {
console.log('Erro Upload profile picture ',error)
console.log('Erro Upload profile picture ', error)
}))
}
+4 -2
View File
@@ -85,14 +85,16 @@ export class ProfilePage implements OnInit {
ngOnInit() {
this.getNotificationData();
this.getProfilpicture();
this.getProfilpicture();
}
getProfilpicture() {
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
console.log(picture)
this.profilePicture = picture
this.profilePicture = 'data:image/jpeg;base64,' +picture
}).catch((error ) => {
this.profilePicture = "";
})