diff --git a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx index b0caf3ce1688d..8446a3652ff97 100644 --- a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx +++ b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx @@ -1,4 +1,5 @@ import copy from "copy-to-clipboard"; +import i18n from "i18next"; import { ArrowUpRightIcon } from "lucide-react"; import { useContext, useEffect } from "react"; import toast from "react-hot-toast"; @@ -22,6 +23,7 @@ const EmbeddedMemo = ({ resourceId: uid, params: paramsStr }: Props) => { const memoStore = useMemoStore(); const memoName = `memos/${uid}`; const memo = memoStore.getMemoByName(memoName); + const isMemoOlderThan24Hours = Date.now() - memo.displayTime!.getTime() > 1000 * 60 * 60 * 24; useEffect(() => { memoStore.getOrFetchMemoByName(memoName).finally(() => loadingState.setFinish()); @@ -69,7 +71,17 @@ const EmbeddedMemo = ({ resourceId: uid, params: paramsStr }: Props) => {
- + {isMemoOlderThan24Hours ? ( + memo.displayTime?.toLocaleString(i18n.resolvedLanguage, { + weekday: "short", + day: "numeric", + month: "short", + hour: "numeric", + minute: "numeric", + }) + ) : ( + + )}
= (props: Props) => { const commentAmount = memo.relations.filter( (relation) => relation.type === MemoRelation_Type.COMMENT && relation.relatedMemo?.name === memo.name, ).length; - const relativeTimeFormat = Date.now() - memo.displayTime!.getTime() > 1000 * 60 * 60 * 24 ? "datetime" : "auto"; + const isMemoOlderThan24Hours = Date.now() - memo.displayTime!.getTime() > 1000 * 60 * 60 * 24; + const relativeTimeFormat = isMemoOlderThan24Hours ? "datetime" : "auto"; const isArchived = memo.state === State.ARCHIVED; const readonly = memo.creator !== user?.name && !isSuperUser(user); const isInMemoDetailPage = location.pathname.startsWith(`/${memo.name}`); @@ -117,6 +119,14 @@ const MemoView: React.FC = (props: Props) => { const displayTime = isArchived ? ( memo.displayTime?.toLocaleString() + ) : isMemoOlderThan24Hours ? ( + memo.displayTime?.toLocaleString(i18n.resolvedLanguage, { + weekday: "short", + day: "numeric", + month: "short", + hour: "numeric", + minute: "numeric", + }) ) : ( );