mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
added "scroll down" notification in mini cache
This commit is contained in:
@@ -3,11 +3,18 @@ import DialogContent from '@material-ui/core/DialogContent'
|
|||||||
import { Stage, Layer } from 'react-konva'
|
import { Stage, Layer } from 'react-konva'
|
||||||
import Measure from 'react-measure'
|
import Measure from 'react-measure'
|
||||||
import isEqual from 'lodash/isEqual'
|
import isEqual from 'lodash/isEqual'
|
||||||
|
import styled from 'styled-components'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
import SingleBlock from './SingleBlock'
|
import SingleBlock from './SingleBlock'
|
||||||
import { useCreateCacheMap } from './customHooks'
|
import { useCreateCacheMap } from './customHooks'
|
||||||
|
|
||||||
|
const ScrollNotification = styled.div`
|
||||||
|
margin-top: 10px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: rgba(0, 0, 0, 0.5);
|
||||||
|
`
|
||||||
|
|
||||||
const TorrentCache = memo(
|
const TorrentCache = memo(
|
||||||
({ cache, isMini }) => {
|
({ cache, isMini }) => {
|
||||||
const [dimensions, setDimensions] = useState({ width: 0, height: 0 })
|
const [dimensions, setDimensions] = useState({ width: 0, height: 0 })
|
||||||
@@ -35,6 +42,8 @@ const TorrentCache = memo(
|
|||||||
updateStageSettings(12, 2)
|
updateStageSettings(12, 2)
|
||||||
}, [isMini, dimensions.width])
|
}, [isMini, dimensions.width])
|
||||||
|
|
||||||
|
const miniCacheMaxHeight = 340
|
||||||
|
|
||||||
const { boxHeight, strokeWidth, marginBetweenBlocks, stageOffset } = stageSettings
|
const { boxHeight, strokeWidth, marginBetweenBlocks, stageOffset } = stageSettings
|
||||||
const preloadPiecesAmount = Math.round(cache.Capacity / cache.PiecesLength - 1)
|
const preloadPiecesAmount = Math.round(cache.Capacity / cache.PiecesLength - 1)
|
||||||
const blockSizeWithMargin = boxHeight + strokeWidth + marginBetweenBlocks
|
const blockSizeWithMargin = boxHeight + strokeWidth + marginBetweenBlocks
|
||||||
@@ -56,10 +65,10 @@ const TorrentCache = memo(
|
|||||||
return (
|
return (
|
||||||
<Measure bounds onResize={({ bounds }) => setDimensions(bounds)}>
|
<Measure bounds onResize={({ bounds }) => setDimensions(bounds)}>
|
||||||
{({ measureRef }) => (
|
{({ measureRef }) => (
|
||||||
<div ref={measureRef}>
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} ref={measureRef}>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
{...(isMini
|
{...(isMini
|
||||||
? { style: { padding: 0, maxHeight: '340px', overflow: 'auto' } }
|
? { style: { padding: 0, maxHeight: `${miniCacheMaxHeight}px`, overflow: 'auto' } }
|
||||||
: { style: { padding: 0 } })}
|
: { style: { padding: 0 } })}
|
||||||
>
|
>
|
||||||
<Stage
|
<Stage
|
||||||
@@ -112,6 +121,8 @@ const TorrentCache = memo(
|
|||||||
</Layer>
|
</Layer>
|
||||||
</Stage>
|
</Stage>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
|
{dimensions.height >= miniCacheMaxHeight && <ScrollNotification>scroll down</ScrollNotification>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Measure>
|
</Measure>
|
||||||
|
|||||||
Reference in New Issue
Block a user