chore: persist selected date of DailyReview page (#2219)

* Persist selected date of DailyReview page

* Use hook useLocalStorage instead of useState

* Update web/src/pages/DailyReview.tsx

Co-authored-by: boojack <stevenlgtm@gmail.com>
Signed-off-by: Athurg Gooth <athurg@gooth.org>

---------

Signed-off-by: Athurg Gooth <athurg@gooth.org>
Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
Athurg Gooth 2023-09-14 19:57:44 +08:00 committed by GitHub
parent 14aa3224ce
commit 41e26f56e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,8 @@
import classNames from "classnames";
import { last } from "lodash-es";
import { useEffect, useRef, useState } from "react";
import { useEffect, useRef } from "react";
import toast from "react-hot-toast";
import useLocalStorage from "react-use/lib/useLocalStorage";
import useToggle from "react-use/lib/useToggle";
import DailyMemo from "@/components/DailyMemo";
import Empty from "@/components/Empty";
@ -23,7 +24,11 @@ const DailyReview = () => {
const userStore = useUserStore();
const user = useCurrentUser();
const { localSetting } = userStore.state.user as User;
const [currentDateStamp, setCurrentDateStamp] = useState(getDateStampByDate(getNormalizedDateString()));
const [currentDateStampRaw, setCurrentDateStamp] = useLocalStorage<number>(
"daily-review-datestamp",
getDateStampByDate(getNormalizedDateString())
);
const currentDateStamp = currentDateStampRaw as number;
const [showDatePicker, toggleShowDatePicker] = useToggle(false);
const memosElRef = useRef<HTMLDivElement>(null);
const currentDate = new Date(currentDateStamp);