mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 15:20:30 +08:00
Fix: go back to previous page when last card on the last page is deleted (#17409)
This commit is contained in:
@@ -110,6 +110,24 @@ export const useGetPaginationWithRouter = () => {
|
||||
};
|
||||
};
|
||||
|
||||
// When the current page becomes empty (e.g. after deleting the last card on
|
||||
// the last page), navigate back to the previous page automatically.
|
||||
export const useGoToPreviousPageOnEmpty = (
|
||||
listLength: number | undefined,
|
||||
loading: boolean = false,
|
||||
) => {
|
||||
const { pagination, setPagination } = useGetPaginationWithRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading && listLength === 0 && pagination.current > 1) {
|
||||
setPagination({
|
||||
page: pagination.current - 1,
|
||||
pageSize: pagination.pageSize,
|
||||
});
|
||||
}
|
||||
}, [listLength, loading, pagination, setPagination]);
|
||||
};
|
||||
|
||||
export const useHandleSearchChange = () => {
|
||||
const [searchString, setSearchString] = useState('');
|
||||
const { pagination, setPagination } = useGetPaginationWithRouter();
|
||||
|
||||
Reference in New Issue
Block a user