Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src-tauri/src/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ pub async fn get_directory_files(
paths: Vec<String>,
search: String,
skip: i64,
take: i64, // Ajout du paramètre take
state: tauri::State<'_, AppState>,
) -> Result<std::vec::Vec<file::Data>, String> {
let take = take.clamp(1, 1000);

let query = state
.prisma_client
.file()
Expand All @@ -125,7 +128,7 @@ pub async fn get_directory_files(
])
.order_by(file::path::order(Direction::Asc));

return match query.skip(skip).take(20).exec().await {
return match query.skip(skip).take(take).exec().await {
Ok(files) => Ok(files),
Err(e) => Err(e.to_string()),
};
Expand Down Expand Up @@ -251,19 +254,8 @@ pub async fn scan_directory(

let mut result = Vec::with_capacity(files.len());

let stop_flag = Arc::new(AtomicBool::new(false));
let stop_flag_clone = stop_flag.clone();

app_handle.once_global("stop-analyze-directory-files".to_string(), move |_| {
stop_flag_clone.store(true, Ordering::SeqCst);
});

let mut iter = files.into_iter();
while let Some(path_file) = iter.next() {
if stop_flag.load(Ordering::SeqCst) {
println!("Analyse arrêtée par l'utilisateur.");
break;
}
let last_part = path_file
.file_name()
.to_str()
Expand Down
2 changes: 1 addition & 1 deletion src/components/FilesTable/FilesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const FilesTable: Component = () => {
return files()?.length || 0;
}
},
overscan: 8,
overscan: 10,
estimateSize: () => 45,
isScrollingResetDelay: 0,
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/FilesTable/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const DEFAULT_ITEM_PER_PAGE = 20;
export const DEFAULT_ITEM_PER_PAGE = 100;
3 changes: 3 additions & 0 deletions src/services/filesServices.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DEFAULT_ITEM_PER_PAGE } from "@/components/FilesTable/constants";
import { MetadataFiles, paddedSplice } from "@/services/helpers/helpers";
import { ISearchState } from "@/stores/store";
import { type File as PrismaFile } from "@prisma/client";
Expand All @@ -21,6 +22,7 @@ export const getDirectoryFiles: ResourceFetcher<
const data = await invoke<PrismaFile[]>("get_directory_files", {
paths,
search,
take: DEFAULT_ITEM_PER_PAGE,
skip: refetching,
});
return paddedSplice(prevValue, refetching, data);
Expand All @@ -29,6 +31,7 @@ export const getDirectoryFiles: ResourceFetcher<
const data = await invoke<PrismaFile[]>("get_directory_files", {
paths,
search,
take: DEFAULT_ITEM_PER_PAGE,
skip: 0,
});

Expand Down