mirror of https://github.com/usememos/memos.git
fix(web): calendar navigation should use current page path (#5605)
This commit is contained in:
parent
b623162d37
commit
b5108b4f97
|
|
@ -1,16 +1,18 @@
|
|||
import { useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import { stringifyFilters } from "@/contexts/MemoFilterContext";
|
||||
|
||||
export const useDateFilterNavigation = () => {
|
||||
export const useDateFilterNavigation = (targetPath?: string) => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const navigateToDateFilter = useCallback(
|
||||
(date: string) => {
|
||||
const filterQuery = stringifyFilters([{ factor: "displayTime", value: date }]);
|
||||
navigate(`/?filter=${filterQuery}`);
|
||||
const basePath = targetPath ?? location.pathname;
|
||||
navigate(`${basePath}?filter=${filterQuery}`);
|
||||
},
|
||||
[navigate],
|
||||
[navigate, location.pathname, targetPath],
|
||||
);
|
||||
|
||||
return navigateToDateFilter;
|
||||
|
|
|
|||
Loading…
Reference in New Issue