fix(view):修复重新加载其他漫画目录后,图片高度记忆不清除的问题。
This commit is contained in:
		| @@ -1,16 +1,20 @@ | ||||
| //@ts-nocheck | ||||
| import { Box } from '@mantine/core'; | ||||
| import { equals } from 'ramda'; | ||||
| import { FC, useLayoutEffect } from 'react'; | ||||
| import { useMeasure } from 'react-use'; | ||||
| import { equals, head } from 'ramda'; | ||||
| import { FC, useLayoutEffect, useMemo } from 'react'; | ||||
| import { useMeasure, useUpdate } from 'react-use'; | ||||
| import { sortedFilesSelector, useFileListStore } from '../states/files'; | ||||
| import { useZoomState } from '../states/zoom'; | ||||
| import { ContinuationView } from './ContinuationView'; | ||||
| import { SingleView } from './SingleView'; | ||||
|  | ||||
| export const ComicView: FC = () => { | ||||
|   const forceUpdate = useUpdate(); | ||||
|   const files = useFileListStore(sortedFilesSelector()); | ||||
|   const viewMode = useZoomState.use.viewMode(); | ||||
|   const updateViewHeight = useZoomState.use.updateViewHeight(); | ||||
|   const [containerRef, { height }] = useMeasure(); | ||||
|   const firstFileId = useMemo(() => head(files)?.id ?? '', [files, files.length]); | ||||
|  | ||||
|   useLayoutEffect(() => { | ||||
|     updateViewHeight(height); | ||||
| @@ -19,7 +23,7 @@ export const ComicView: FC = () => { | ||||
|   return ( | ||||
|     <Box w="100%" h="100%" sx={{ overflow: 'hidden' }} ref={containerRef}> | ||||
|       {equals(viewMode, 'single') && <SingleView />} | ||||
|       {equals(viewMode, 'continuation') && <ContinuationView />} | ||||
|       {equals(viewMode, 'continuation') && <ContinuationView key={firstFileId} />} | ||||
|     </Box> | ||||
|   ); | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user