improve the way wa getting the user profile picture

This commit is contained in:
Peter Maquiran
2024-07-25 09:32:45 +01:00
parent 20c50318b2
commit 971a73f0a3
3 changed files with 32 additions and 41 deletions
@@ -45,7 +45,7 @@ export class EditProfilePage implements OnInit {
private httpErrorHandle: HttpErrorHandle,
private UserRepositoryService: UserRepositoryService
) {
) {
this.profilePictureSubject = this.UserRepositoryService.getProfilePictureLive() as any
}
@@ -165,7 +165,7 @@ export class EditProfilePage implements OnInit {
}
CameraSource = CameraSource
@XTracerAsync({name:'edit-profile/takePicture', bugPrint: true, autoFinish: false})
@XTracerAsync({name:'edit-profile/takePicture', bugPrint: true})
async uploadPicture(source: CameraSource, tracing?: TracingType) {
const capturedImage = await this.CameraService.takePicture({
@@ -186,7 +186,7 @@ export class EditProfilePage implements OnInit {
const guid = await this.UserRepositoryService.addUserProfilePhoto(object)
if(guid.isOk()) {
tracing.addEvent('upload image')
@@ -194,23 +194,16 @@ export class EditProfilePage implements OnInit {
if(base.isOk()) {
tracing.addEvent('download image')
this.storageService.store(this.SessionStore.user.RoleID.toString(), 'data:image/jpeg;base64,'+base.value).then((value) => {
tracing.addEvent('store image in')
this.profilePicture = 'data:image/jpeg;base64,' + base.value;
tracing.setAttribute("picture.save", "true")
tracing.finish()
}).catch((error) => {
tracing.setAttribute("picture.save", "false")
tracing.finish()
});
this.profilePicture = 'data:image/jpeg;base64,' + base.value;
tracing.setAttribute("picture.save", "true")
} else {
if(!isHttpError(base.error)) {
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.')
} else {
this.httpErrorHandle.httpStatusHandle(base.error)
}
tracing.finish()
}
} else {
@@ -219,9 +212,8 @@ export class EditProfilePage implements OnInit {
} else {
this.httpErrorHandle.httpStatusHandle(guid.error)
}
tracing.finish()
}
}
}