improve profile reactiveness and action page performance

This commit is contained in:
Peter Maquiran
2024-07-24 13:37:02 +01:00
parent 717968ac52
commit 46bb078dd2
45 changed files with 543 additions and 247 deletions
@@ -0,0 +1,47 @@
import { Injectable } from '@angular/core';
import { UserRemoteRepositoryService } from './datasource/user-remote-repository.service';
import { IProfilePictureInputDTO } from './dto/profilePictureInputDTO';
import { UserLocalRepositoryService } from './datasource/user-local-repository.service';
import { TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
@Injectable({
providedIn: 'root'
})
export class UserRepositoryService {
constructor(
private remote: UserRemoteRepositoryService,
private local: UserLocalRepositoryService
) { }
async getUserProfilePhoto(guid: string , tracing?: TracingType) {
const result = await this.remote.getUserProfilePhoto(guid)
if(result.isOk()) {
this.local.addProfilePicture({base64: 'data:image/jpeg;base64,' + result.value})
} else {
tracing?.setAttribute("picture.upload", "false")
tracing?.hasError("cant upload picture")
}
return result
}
async addUserProfilePhoto(data: IProfilePictureInputDTO, tracing?: TracingType) {
const result = await this.remote.addUserProfilePhoto(data)
if(result.isOk()) {
this.local.addProfilePicture({base64: 'data:image/jpeg;base64,' + data.ImageBase64})
} else {
tracing?.setAttribute("picture.upload", "false")
tracing?.hasError("cant upload picture")
}
return result
}
getProfilePictureLive() {
return this.local.getLiveProfilePicture()
}
}