1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

Create New Method for Setting Avatar Color from Sync (#8403)

This commit is contained in:
Justin Baur
2024-03-20 14:28:22 -05:00
committed by GitHub
parent 1400ec9c16
commit ec5c6b6797
3 changed files with 17 additions and 1 deletions

View File

@@ -15,6 +15,17 @@ export abstract class AvatarService {
* @returns a promise that resolves when the avatar color is set
*/
abstract setAvatarColor(color: string): Promise<void>;
/**
* Sets the avatar color for the given user, meant to be used via sync.
*
* @remarks This is meant to be used for getting an updated avatar color from
* the sync endpoint. If the user is changing their avatar color
* on device, you should instead call {@link setAvatarColor}.
*
* @param userId The user id for the user to set the avatar color for
* @param color The color to set the avatar color to
*/
abstract setSyncAvatarColor(userId: UserId, color: string): Promise<void>;
/**
* Gets the avatar color of the specified user.
*

View File

@@ -27,6 +27,10 @@ export class AvatarService implements AvatarServiceAbstraction {
await this.stateProvider.setUserState(AVATAR_COLOR, avatarColor);
}
async setSyncAvatarColor(userId: UserId, color: string): Promise<void> {
await this.stateProvider.getUser(userId, AVATAR_COLOR).update(() => color);
}
getUserAvatarColor$(userId: UserId): Observable<string | null> {
return this.stateProvider.getUser(userId, AVATAR_COLOR).state$;
}