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:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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$;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user