Compare commits
No commits in common. "f618d1442c93e2d9c99ca37e2534b1aac109230c" and "06f94fe27e263ad283afe3b02d29da7bb73409b2" have entirely different histories.
f618d1442c
...
06f94fe27e
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@ -339,7 +339,6 @@ dependencies = [
|
||||
"tauri-build",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"uuid 1.3.0",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
|
@ -24,7 +24,6 @@ walkdir = "2.3.2"
|
||||
serde_repr = "0.1.10"
|
||||
tokio = { version = "1.23.1", features = ["full"] }
|
||||
image = "0.24.5"
|
||||
uuid = "1.3.0"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
||||
|
@ -4,7 +4,6 @@ use walkdir::WalkDir;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct FileItem {
|
||||
pub id: String,
|
||||
pub filename: String,
|
||||
pub path: String,
|
||||
pub height: u32,
|
||||
@ -20,7 +19,6 @@ pub fn scan_directory(target: String) -> Result<Vec<FileItem>, String> {
|
||||
.map(|f| {
|
||||
let (width, height) = image::image_dimensions(f.path())?;
|
||||
Ok(FileItem {
|
||||
id: uuid::Uuid::new_v4().to_string(),
|
||||
filename: f
|
||||
.path()
|
||||
.file_name()
|
||||
|
@ -1,20 +1,16 @@
|
||||
//@ts-nocheck
|
||||
import { Box } from '@mantine/core';
|
||||
import { equals, head } from 'ramda';
|
||||
import { FC, useLayoutEffect, useMemo } from 'react';
|
||||
import { useMeasure, useUpdate } from 'react-use';
|
||||
import { sortedFilesSelector, useFileListStore } from '../states/files';
|
||||
import { equals } from 'ramda';
|
||||
import { FC, useLayoutEffect } from 'react';
|
||||
import { useMeasure } from 'react-use';
|
||||
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);
|
||||
@ -23,7 +19,7 @@ export const ComicView: FC = () => {
|
||||
return (
|
||||
<Box w="100%" h="100%" sx={{ overflow: 'hidden' }} ref={containerRef}>
|
||||
{equals(viewMode, 'single') && <SingleView />}
|
||||
{equals(viewMode, 'continuation') && <ContinuationView key={firstFileId} />}
|
||||
{equals(viewMode, 'continuation') && <ContinuationView />}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
@ -21,7 +21,6 @@ export const ContinuationView: FC = () => {
|
||||
},
|
||||
[files]
|
||||
);
|
||||
const fileHeights = useMemo(() => map(item => item.height * (zoom / 100), files), [files, zoom]);
|
||||
|
||||
useEffect(() => {
|
||||
ebus?.addListener('navigate_offset', ({ filename }) => {
|
||||
@ -49,8 +48,7 @@ export const ContinuationView: FC = () => {
|
||||
<VariableSizeList
|
||||
itemData={files}
|
||||
itemCount={fileCount}
|
||||
itemSize={index => fileHeights[index]}
|
||||
itemKey={index => files[index].id}
|
||||
itemSize={index => files[index].height * (zoom / 100)}
|
||||
height={viewHeight}
|
||||
width="100%"
|
||||
ref={virtualListRef}
|
||||
|
@ -1,6 +1,5 @@
|
||||
export type FileItem = {
|
||||
sort: number;
|
||||
id: string;
|
||||
filename: string;
|
||||
path: string;
|
||||
width: number;
|
||||
|
Loading…
x
Reference in New Issue
Block a user