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