From 32521e1178d912f2b101d62c6c48ba3462c52eb1 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Sun, 12 Jun 2022 16:06:02 +0800 Subject: [PATCH] add routes for FilesInFolder "o": string, offset of the result --- web/src/component/FilesInFolder.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web/src/component/FilesInFolder.js b/web/src/component/FilesInFolder.js index 473b252..e539788 100644 --- a/web/src/component/FilesInFolder.js +++ b/web/src/component/FilesInFolder.js @@ -1,12 +1,16 @@ import { useParams } from "react-router"; import { useState, useEffect } from "react"; +import { useNavigate } from "react-router-dom"; +import { useQuery } from "./Common"; import FilesTable from "./FilesTable"; function FilesInFolder(props) { let params = useParams(); + const query = useQuery(); + const navigator = useNavigate(); const [files, setFiles] = useState([]); const [isLoading, setIsLoading] = useState(false); - const [offset, setOffset] = useState(0); + const offset = parseInt(query.get("o")) || 0; const [newFoldername, setNewFoldername] = useState(""); const limit = 10; @@ -43,7 +47,7 @@ function FilesInFolder(props) { }, [params.id, offset]); function nextPage() { - setOffset(offset + limit); + navigator(`/folders/${params.id}?o=${offset + limit}`); } function lastPage() { @@ -51,7 +55,7 @@ function FilesInFolder(props) { if (offsetValue < 0) { return; } - setOffset(offsetValue); + navigator(`/folders/${params.id}?o=${offsetValue}`); } function updateFoldername() {