fix(web): keep editor timestamp update-only

Preserve creation-time visibility only in lists sorted by creation time.\n\nRefs #346
This commit is contained in:
tianma-if committed 2026-09-04 20:33:38 +08:00
1 parent 5d1c76a41c
commit be2fec7591
5 files changed
+4 -31

No files matched your search

+3 -5
View File
@@ -114,7 +114,7 @@ import { ShareNoteImageDialog, type ShareNoteImageSource } from "./dialogs/Share
import { AiAssistantDialog, type AiAssistantAnchor } from "./dialogs/AiAssistantDialog";
import { api } from "@/lib/api";
import { isDesktopResourceRuntime, stageDesktopResource, toDesktopResourceUrl } from "@/lib/desktop-resources";
import { cn, formatDateTime, formatLocalizedDateTime, parseTagsText } from "@/lib/utils";
import { cn, formatDateTime, parseTagsText } from "@/lib/utils";
import { EDITOR_CONTENT_MAX_WIDTH, EDITOR_CONTENT_MAX_WIDTH_COLLAPSED } from "@/lib/workspace-ui";
import {
countMemoCharacters,
@@ -3639,9 +3639,7 @@ const RichEditorPane = ({
? "bg-emerald-50 text-emerald-700"
: saveStateClassName;
const memoDateLocale = i18n.resolvedLanguage ?? i18n.language;
const createdLabel = formatLocalizedDateTime(memo.createdAt, memoDateLocale);
const updatedLabel = formatLocalizedDateTime(memo.updatedAt, memoDateLocale);
const updatedLabel = formatDateTime(memo.updatedAt);
const currentNotebookLabel = notebookOptions.find((notebook) => notebook.id === memo.notebookId)?.name ?? t("editor.notebookFallback");
const currentMarkdownForAi = getCurrentMarkdownForAi();
@@ -3883,7 +3881,7 @@ const RichEditorPane = ({
</IconTooltip>
</div>
<span className="hidden truncate text-xs text-slate-400 sm:inline">
{t("editor.timestamps", { createdTime: createdLabel, updatedTime: updatedLabel })}
{t("editor.updatedAt", { time: updatedLabel })}
</span>
</div>
+1 -11
View File
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { buildNotebookTree, formatLocalizedDateTime, parseTagsText } from "./utils.ts";
import { buildNotebookTree, parseTagsText } from "./utils.ts";
const notebook = (id, parentId, memoCount, lastMemoUpdatedAt = null) => ({
id,
@@ -65,13 +65,3 @@ describe("tag text parsing", () => {
]);
});
});
describe("localized date formatting", () => {
test("includes the year for historical memo timestamps", () => {
expect(formatLocalizedDateTime("2010-08-30T12:34:00.000Z", "en-US")).toContain("2010");
});
test("fails gracefully for invalid timestamps", () => {
expect(formatLocalizedDateTime("not-a-date", "zh-CN")).toBe("");
});
});
-13
View File
@@ -57,19 +57,6 @@ export const formatDateTime = (value: string) =>
minute: "2-digit",
}).format(new Date(value));
export const formatLocalizedDateTime = (value: string, locale: string) => {
const date = new Date(value);
if (Number.isNaN(date.getTime())) return "";
return new Intl.DateTimeFormat(locale, {
year: "numeric",
month: "numeric",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
}).format(date);
};
export const parseTagsText = (value: string) =>
value
.split(/[,,\n]+/)
-1
View File
@@ -1427,7 +1427,6 @@ export const enUS = {
enableReadingProtection: "Enable reading protection",
disableReadingProtection: "Disable reading protection and edit",
updatedAt: "Updated {{time}}",
timestamps: "Created {{createdTime}} · Updated {{updatedTime}}",
done: "Done",
uploadAttachment: "Upload attachment",
collapseFormat: "Collapse formatting",
-1
View File
@@ -1427,7 +1427,6 @@ export const zhCN = {
enableReadingProtection: "开启阅读保护",
disableReadingProtection: "关闭阅读保护并进入编辑",
updatedAt: "更新于 {{time}}",
timestamps: "创建于 {{createdTime}} · 更新于 {{updatedTime}}",
done: "完成",
uploadAttachment: "上传附件",
collapseFormat: "收起格式",