import { Box } from "@mui/material"; import { useState, useEffect } from "react"; import { ReactPhotoSphereViewer } from "react-photo-sphere-viewer"; import { ThreeView } from "./ThreeView"; import { ThreeViewErrorBoundary } from "./ThreeViewErrorBoundary"; import { clearMediaTransitionCache } from "../../shared/lib/gltfCacheManager"; export interface MediaData { id: string | number; media_type: number; filename?: string; } export function MediaViewer({ media, className, height, width, fullWidth, fullHeight, }: Readonly<{ media?: MediaData; className?: string; height?: string; width?: string; fullWidth?: boolean; fullHeight?: boolean; }>) { const token = localStorage.getItem("token"); const [resetKey, setResetKey] = useState(0); const [previousMediaId, setPreviousMediaId] = useState< string | number | null >(null); useEffect(() => { if (media?.id !== previousMediaId) { // Используем новый cache manager для очистки кеша clearMediaTransitionCache( previousMediaId, media?.media_type ); setResetKey(0); setPreviousMediaId(media?.id || null); } }, [media?.id, media?.media_type, previousMediaId]); const handleReset = () => { setResetKey((prev) => { const newKey = prev + 1; return newKey; }); }; return ( {media?.media_type === 1 && ( {media?.filename} )} {media?.media_type === 2 && ( ); }