setDimensions(bounds)}>
- {({ measureRef }) => (
-
-
-
-
- {isMini
- ? shortCacheMap.map(({ percentage, isComplete, inProgress, isActive, isReaderRange }, i) => {
- const { x, y } = getItemCoordinates(i)
-
- return (
-
- )
- })
- : cacheMap.map(({ id, percentage, isComplete, inProgress, isActive, isReaderRange }) => {
- const { x, y } = getItemCoordinates(id)
-
- return (
-
- )
- })}
-
-
-
-
- {isMini &&
- (stageOffset + blockSizeWithMargin * amountOfRows || 0) >= miniCacheMaxHeight &&
- dimensions.height >= miniCacheMaxHeight && {t('ScrollDown')}}
-
- )}
-
- )
-}
diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/LargeSnake.jsx b/web/src/components/DialogTorrentDetailsContent/TorrentCache/LargeSnake.jsx
deleted file mode 100644
index 05cb2bc..0000000
--- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/LargeSnake.jsx
+++ /dev/null
@@ -1,114 +0,0 @@
-import styled, { css } from 'styled-components'
-import Measure from 'react-measure'
-import { useState } from 'react'
-import { v4 as uuidv4 } from 'uuid'
-import { useTranslation } from 'react-i18next'
-
-import {
- defaultBackgroundColor,
- defaultBorderColor,
- progressColor,
- completeColor,
- activeColor,
- rangeColor,
-} from './colors'
-import getShortCacheMap from './getShortCacheMap'
-
-const borderWidth = 1
-const defaultPieceSize = 14
-const pieceSizeForMiniMap = 23
-const gapBetweenPieces = 3
-const miniCacheMaxHeight = 340
-
-const ScrollNotification = styled.div`
- margin-top: 10px;
- text-transform: uppercase;
- color: rgba(0, 0, 0, 0.5);
- align-self: center;
-`
-
-const SnakeWrapper = styled.div`
- ${({ pieceSize, piecesInOneRow }) => css`
- display: grid;
- gap: ${gapBetweenPieces}px;
- grid-template-columns: repeat(${piecesInOneRow || 'auto-fit'}, ${pieceSize}px);
- grid-auto-rows: max-content;
- justify-content: center;
-
- ${piecesInOneRow &&
- css`
- max-height: ${miniCacheMaxHeight}px;
- overflow: auto;
- `}
-
- .piece {
- width: ${pieceSize}px;
- height: ${pieceSize}px;
- background: ${defaultBackgroundColor};
- border: ${borderWidth}px solid ${defaultBorderColor};
- display: grid;
- align-items: end;
-
- &-loading {
- background: ${progressColor};
- border-color: ${progressColor};
- }
- &-complete {
- background: ${completeColor};
- border-color: ${completeColor};
- }
- &-reader {
- border-color: ${activeColor};
- }
- }
-
- .reader-range {
- border-color: ${rangeColor};
- }
- `}
-`
-
-const PercentagePiece = styled.div`
- background: ${completeColor};
- height: ${({ percentage }) => (percentage / 100) * 12}px;
-`
-
-export default function LargeSnake({ cacheMap, isMini, preloadPiecesAmount }) {
- const { t } = useTranslation()
- const [dimensions, setDimensions] = useState({ width: 0, height: 0 })
- const pieceSize = isMini ? pieceSizeForMiniMap : defaultPieceSize
-
- let piecesInOneRow
- let shotCacheMap
- if (isMini) {
- const pieceSizeWithGap = pieceSize + gapBetweenPieces
- piecesInOneRow = Math.floor((dimensions.width * 0.95) / pieceSizeWithGap)
- shotCacheMap = isMini && getShortCacheMap({ cacheMap, preloadPiecesAmount, piecesInOneRow })
- }
-
- return isMini ? (
-