33 lines
1023 B
TypeScript
33 lines
1023 B
TypeScript
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
import { AvatarDisplay } from "../display-objects/AvatarDisplay";
|
|
import { AvatarViewData } from "@/lib/view-data/AvatarViewData";
|
|
|
|
/**
|
|
* Avatar View Model
|
|
*
|
|
* Represents avatar information for the UI layer.
|
|
* Transforms AvatarViewData into UI-ready state with formatting and derived fields.
|
|
*/
|
|
export class AvatarViewModel extends ViewModel {
|
|
private readonly data: AvatarViewData;
|
|
|
|
constructor(data: AvatarViewData) {
|
|
super();
|
|
this.data = data;
|
|
}
|
|
|
|
/** UI-specific: Buffer is already base64 encoded in ViewData */
|
|
get bufferBase64(): string {
|
|
return this.data.buffer;
|
|
}
|
|
|
|
/** UI-specific: Derive content type label using Display Object */
|
|
get contentTypeLabel(): string {
|
|
return AvatarDisplay.formatContentType(this.data.contentType);
|
|
}
|
|
|
|
/** UI-specific: Derive validity check using Display Object */
|
|
get hasValidData(): boolean {
|
|
return AvatarDisplay.hasValidData(this.data.buffer, this.data.contentType);
|
|
}
|
|
} |