diff --git a/web/src/components/DailyReviewDialog.tsx b/web/src/components/DailyReviewDialog.tsx index 6a4abd54..9ce841e9 100644 --- a/web/src/components/DailyReviewDialog.tsx +++ b/web/src/components/DailyReviewDialog.tsx @@ -1,6 +1,6 @@ import { useRef, useState } from "react"; import { useTranslation } from "react-i18next"; -import { useMemoStore } from "../store/module"; +import { useMemoStore, useUserStore } from "../store/module"; import toImage from "../labs/html2image"; import useToggle from "../hooks/useToggle"; import { DAILY_TIMESTAMP } from "../helpers/consts"; @@ -23,17 +23,23 @@ const DailyReviewDialog: React.FC = (props: Props) => { const { t } = useTranslation(); const memoStore = useMemoStore(); const memos = memoStore.state.memos; + + const userStore = useUserStore(); + const { localSetting } = userStore.state.user as User; const [currentDateStamp, setCurrentDateStamp] = useState(utils.getDateStampByDate(utils.getDateString(props.currentDateStamp))); const [showDatePicker, toggleShowDatePicker] = useToggle(false); const memosElRef = useRef(null); const currentDate = new Date(currentDateStamp); const dailyMemos = memos - .filter( - (m) => + .filter((m) => { + const createdTimestamp = utils.getTimeStampByDate(m.createdTs); + const currentDateStampWithOffset = currentDateStamp + utils.convertToMillis(localSetting); + return ( m.rowStatus === "NORMAL" && - utils.getTimeStampByDate(m.createdTs) >= currentDateStamp && - utils.getTimeStampByDate(m.createdTs) < currentDateStamp + DAILY_TIMESTAMP - ) + createdTimestamp >= currentDateStampWithOffset && + createdTimestamp < currentDateStampWithOffset + DAILY_TIMESTAMP + ); + }) .sort((a, b) => utils.getTimeStampByDate(a.createdTs) - utils.getTimeStampByDate(b.createdTs)); const handleShareBtnClick = () => { diff --git a/web/src/components/Settings/PreferencesSection.tsx b/web/src/components/Settings/PreferencesSection.tsx index 79708f34..d88101f9 100644 --- a/web/src/components/Settings/PreferencesSection.tsx +++ b/web/src/components/Settings/PreferencesSection.tsx @@ -20,6 +20,8 @@ const PreferencesSection = () => { }; }); + const dailyReviewTimeOffsetOptions: number[] = [...Array(24).keys()]; + const handleLocaleSelectChange = async (locale: Locale) => { await userStore.upsertUserSetting("locale", locale); globalStore.setLocale(locale); @@ -46,6 +48,10 @@ const PreferencesSection = () => { userStore.upsertLocalSetting({ ...localSetting, enableDoubleClickEditing: event.target.checked }); }; + const handleDailyReviewTimeOffsetChanged = (value: number) => { + userStore.upsertLocalSetting({ ...localSetting, dailyReviewTimeOffset: value }); + }; + return (

{t("common.basic")}

@@ -94,6 +100,37 @@ const PreferencesSection = () => { ))}
+ +
+ Daily Review Time Offset + + + +
+