refactor: type-safety

This commit is contained in:
Maze Winther
2025-08-26 11:51:08 +02:00
parent 9497bef10a
commit 2f7cd11ca1
@@ -38,6 +38,7 @@ import {
import { cn, generateUUID } from "@/lib/utils"; import { cn, generateUUID } from "@/lib/utils";
import { TIMELINE_CONSTANTS } from "@/constants/timeline-constants"; import { TIMELINE_CONSTANTS } from "@/constants/timeline-constants";
import Image from "next/image"; import Image from "next/image";
import type { MediaItem } from "@/stores/media-store";
import { DraggableMediaItem } from "@/components/ui/draggable-item"; import { DraggableMediaItem } from "@/components/ui/draggable-item";
import { InputWithBack } from "@/components/ui/input-with-back"; import { InputWithBack } from "@/components/ui/input-with-back";
import { StickerCategory } from "@/stores/stickers-store"; import { StickerCategory } from "@/stores/stickers-store";
@@ -286,9 +287,9 @@ function StickersContentView({ category }: { category: StickerCategory }) {
throw new Error("Failed to download sticker"); throw new Error("Failed to download sticker");
} }
const mediaItem = { const mediaItem: Omit<MediaItem, "id"> = {
name: iconName.replace(":", "-"), name: iconName.replace(":", "-"),
type: "image" as const, type: "image",
file, file,
url: URL.createObjectURL(file), url: URL.createObjectURL(file),
width: 200, width: 200,
@@ -565,7 +566,12 @@ interface StickerItemProps {
capSize?: boolean; capSize?: boolean;
} }
function StickerItem({ iconName, onAdd, isAdding, capSize = false }: StickerItemProps) { function StickerItem({
iconName,
onAdd,
isAdding,
capSize = false,
}: StickerItemProps) {
const [imageError, setImageError] = useState(false); const [imageError, setImageError] = useState(false);
const [hostIndex, setHostIndex] = useState(0); const [hostIndex, setHostIndex] = useState(0);
@@ -601,7 +607,10 @@ function StickerItem({ iconName, onAdd, isAdding, capSize = false }: StickerItem
className="w-full h-full object-contain" className="w-full h-full object-contain"
style={ style={
capSize capSize
? { maxWidth: "var(--sticker-max, 160px)", maxHeight: "var(--sticker-max, 160px)" } ? {
maxWidth: "var(--sticker-max, 160px)",
maxHeight: "var(--sticker-max, 160px)",
}
: undefined : undefined
} }
onError={() => { onError={() => {