Skip to content

Commit 332d32b

Browse files
committed
fix: render dates correctly in memo detail sidebar and link dialog
Convert protobuf Timestamp objects to Date before formatting to prevent "[object Object]" from appearing in the UI. Fixes #5368
1 parent be7ef74 commit 332d32b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

web/src/components/MemoDetailSidebar/MemoDetailSidebar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { create } from "@bufbuild/protobuf";
2+
import { timestampDate } from "@bufbuild/protobuf/wkt";
23
import { isEqual } from "lodash-es";
34
import { CheckCircleIcon, Code2Icon, HashIcon, LinkIcon } from "lucide-react";
45
import { cn } from "@/lib/utils";
@@ -36,14 +37,14 @@ const MemoDetailSidebar = ({ memo, className, parentPage }: Props) => {
3637
<p className="flex flex-row justify-start items-center w-full gap-1 mb-1 text-sm leading-6 text-muted-foreground select-none">
3738
<span>{t("common.created-at")}</span>
3839
</p>
39-
<p className="text-sm text-muted-foreground">{memo.createTime?.toLocaleString()}</p>
40+
<p className="text-sm text-muted-foreground">{memo.createTime && timestampDate(memo.createTime).toLocaleString()}</p>
4041
</div>
4142
{!isEqual(memo.createTime, memo.updateTime) && (
4243
<div className="w-full flex flex-col">
4344
<p className="flex flex-row justify-start items-center w-full gap-1 mb-1 text-sm leading-6 text-muted-foreground select-none">
4445
<span>{t("common.last-updated-at")}</span>
4546
</p>
46-
<p className="text-sm text-muted-foreground">{memo.updateTime?.toLocaleString()}</p>
47+
<p className="text-sm text-muted-foreground">{memo.updateTime && timestampDate(memo.updateTime).toLocaleString()}</p>
4748
</div>
4849
)}
4950
{hasSpecialProperty && (

web/src/components/MemoEditor/components/LinkMemoDialog.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { timestampDate } from "@bufbuild/protobuf/wkt";
12
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
23
import { Input } from "@/components/ui/input";
34
import { Memo } from "@/types/proto/api/v1/memo_service_pb";
@@ -75,7 +76,9 @@ export const LinkMemoDialog = ({
7576
onClick={() => onSelectMemo(memo)}
7677
>
7778
<div className="w-full flex flex-col justify-start items-start">
78-
<p className="text-xs text-muted-foreground select-none">{memo.displayTime?.toLocaleString()}</p>
79+
<p className="text-xs text-muted-foreground select-none">
80+
{memo.displayTime && timestampDate(memo.displayTime).toLocaleString()}
81+
</p>
7982
<p className="mt-0.5 text-sm leading-5 line-clamp-2">
8083
{searchText ? highlightSearchText(memo.content, searchText) : memo.snippet}
8184
</p>

0 commit comments

Comments
 (0)