view data fixes
This commit is contained in:
@@ -9,21 +9,25 @@ import { AvatarViewData } from "@/lib/view-data/AvatarViewData";
|
||||
* Transforms AvatarViewData into UI-ready state with formatting and derived fields.
|
||||
*/
|
||||
export class AvatarViewModel extends ViewModel {
|
||||
// UI-specific derived fields (primitive outputs only)
|
||||
readonly bufferBase64: string;
|
||||
readonly contentTypeLabel: string;
|
||||
readonly hasValidData: boolean;
|
||||
private readonly data: AvatarViewData;
|
||||
|
||||
constructor(viewData: AvatarViewData) {
|
||||
constructor(data: AvatarViewData) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
// Buffer is already base64 encoded in ViewData
|
||||
this.bufferBase64 = viewData.buffer;
|
||||
/** UI-specific: Buffer is already base64 encoded in ViewData */
|
||||
get bufferBase64(): string {
|
||||
return this.data.buffer;
|
||||
}
|
||||
|
||||
// Derive content type label using Display Object
|
||||
this.contentTypeLabel = AvatarDisplay.formatContentType(viewData.contentType);
|
||||
/** UI-specific: Derive content type label using Display Object */
|
||||
get contentTypeLabel(): string {
|
||||
return AvatarDisplay.formatContentType(this.data.contentType);
|
||||
}
|
||||
|
||||
// Derive validity check using Display Object
|
||||
this.hasValidData = AvatarDisplay.hasValidData(viewData.buffer, viewData.contentType);
|
||||
/** UI-specific: Derive validity check using Display Object */
|
||||
get hasValidData(): boolean {
|
||||
return AvatarDisplay.hasValidData(this.data.buffer, this.data.contentType);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user