diff --git a/web/src/components/DialogCacheInfo/index.jsx b/web/src/components/DialogCacheInfo/index.jsx index f78ac5e..79c6a29 100644 --- a/web/src/components/DialogCacheInfo/index.jsx +++ b/web/src/components/DialogCacheInfo/index.jsx @@ -15,14 +15,14 @@ export default function DialogCacheInfo({ hash }) { const timerID = useRef(null) const componentIsMounted = useRef(true) const [dimensions, setDimensions] = useState({ width: -1, height: -1 }) + const [isShortView, setIsShortView] = useState(true) + const [isLoading, setIsLoading] = useState(true) const [stageSettings, setStageSettings] = useState({ boxHeight: null, strokeWidth: null, marginBetweenBlocks: null, stageOffset: null, }) - const [isShortView, setIsShortView] = useState(true) - const [isLoading, setIsLoading] = useState(true) const updateStageSettings = (boxHeight, strokeWidth) => { setStageSettings({ @@ -33,9 +33,6 @@ export default function DialogCacheInfo({ hash }) { }) } - const { boxHeight, strokeWidth, marginBetweenBlocks, stageOffset } = stageSettings - let activeId = null - useEffect(() => { // initializing stageSettings updateStageSettings(24, 4) @@ -92,6 +89,8 @@ export default function DialogCacheInfo({ hash }) { setIsLoading(false) }, [cache]) + const { boxHeight, strokeWidth, marginBetweenBlocks, stageOffset } = stageSettings + const preloadPiecesAmount = Math.round(cache.Capacity / cache.PiecesLength - 1) const blockSizeWithMargin = boxHeight + strokeWidth + marginBetweenBlocks const piecesInOneRow = Math.floor((dimensions.width * 0.9) / blockSizeWithMargin) @@ -100,6 +99,7 @@ export default function DialogCacheInfo({ hash }) { ? preloadPiecesAmount - 1 : preloadPiecesAmount + piecesInOneRow - (preloadPiecesAmount % piecesInOneRow) - 1 const amountOfRows = Math.ceil((isShortView ? amountOfBlocksToRenderInShortView : pMap.length) / piecesInOneRow) + let activeId = null return ( setDimensions(contentRect.bounds)}>