We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 07b1c02 commit 3936d70Copy full SHA for 3936d70
src/api/Visualization/types.ts
@@ -148,7 +148,15 @@ export interface IVisualizationTimeline {
148
}
149
150
export interface VisualizationThumbnailData {
151
- svg: string;
+ svg: string; // Should not exceed a certain size, cf isThumbnailTooLarge
152
+}
153
+
154
+export const MAX_VISUALIZATION_THUMBNAIL_SIZE_BYTES = 2_097_152; // 2MB
155
156
+export function isThumbnailTooLarge(thumbnail: VisualizationThumbnailData | undefined): boolean {
157
+ const thumbnailContent = thumbnail?.svg ?? '';
158
+ const thumbnailSizeBytes = new TextEncoder().encode(thumbnailContent).byteLength;
159
+ return thumbnailSizeBytes > MAX_VISUALIZATION_THUMBNAIL_SIZE_BYTES;
160
161
162
export interface BaseVisualization {
0 commit comments