mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
* Use typescript-strict-plugin to iteratively turn on strict * Add strict testing to pipeline Can be executed locally through either `npm run test:types` for full type checking including spec files, or `npx tsc-strict` for only tsconfig.json included files. * turn on strict for scripts directory * Use plugin for all tsconfigs in monorepo vscode is capable of executing tsc with plugins, but uses the most relevant tsconfig to do so. If the plugin is not a part of that config, it is skipped and developers get no feedback of strict compile time issues. These updates remedy that at the cost of slightly more complex removal of the plugin when the time comes. * remove plugin from configs that extend one that already has it * Update workspace settings to honor strict plugin * Apply strict-plugin to native message test runner * Update vscode workspace to use root tsc version * `./node_modules/.bin/update-strict-comments` 🤖 This is a one-time operation. All future files should adhere to strict type checking. * Add fixme to `ts-strict-ignore` comments * `update-strict-comments` 🤖 repeated for new merge files
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
// FIXME: Update this file to be type safe and remove this and next line
|
|
// @ts-strict-ignore
|
|
import { Observable } from "rxjs";
|
|
|
|
import { UserId } from "../../types/guid";
|
|
|
|
export abstract class AvatarService {
|
|
/**
|
|
* An observable monitoring the active user's avatar color.
|
|
* The observable updates when the avatar color changes.
|
|
*/
|
|
avatarColor$: Observable<string | null>;
|
|
/**
|
|
* Sets the avatar color of the active user
|
|
*
|
|
* @param color the color to set the avatar color to
|
|
* @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.
|
|
*
|
|
* @remarks This is most useful for account switching where we show an
|
|
* avatar for each account. If you only need the active user's
|
|
* avatar color, use the avatarColor$ observable above instead.
|
|
*
|
|
* @param userId the userId of the user whose avatar color should be retreived
|
|
* @return an Observable that emits a string of the avatar color of the specified user
|
|
*/
|
|
abstract getUserAvatarColor$(userId: UserId): Observable<string | null>;
|
|
}
|