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() } }