mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
improve profile reactiveness and action page performance
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user