From 06aca3d3ca79f9907cb1a4f80f8ff7e681f762d5 Mon Sep 17 00:00:00 2001 From: Eugene Fox Date: Thu, 8 May 2025 02:20:44 +0300 Subject: [PATCH] fix: show timestamp-based title in edit dialog title placeholder --- entrypoints/sidepanel/components/EditDialog.tsx | 2 +- entrypoints/sidepanel/utils/getCollectionTitle.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/entrypoints/sidepanel/components/EditDialog.tsx b/entrypoints/sidepanel/components/EditDialog.tsx index a863891..aa70c30 100644 --- a/entrypoints/sidepanel/components/EditDialog.tsx +++ b/entrypoints/sidepanel/components/EditDialog.tsx @@ -74,7 +74,7 @@ export default function EditDialog(props: GroupEditDialogProps): ReactElement contentBefore={ } disabled={ color === "pinned" } placeholder={ - props.type === "collection" ? getCollectionTitle(props.collection) : "" + props.type === "collection" ? getCollectionTitle(props.collection, true) : "" } value={ color === "pinned" ? i18n.t("groups.pinned") : title } onChange={ (_, e) => setTitle(e.value) } /> diff --git a/entrypoints/sidepanel/utils/getCollectionTitle.ts b/entrypoints/sidepanel/utils/getCollectionTitle.ts index aa55bc2..c6eb39e 100644 --- a/entrypoints/sidepanel/utils/getCollectionTitle.ts +++ b/entrypoints/sidepanel/utils/getCollectionTitle.ts @@ -1,8 +1,10 @@ import { CollectionItem } from "@/models/CollectionModels"; -export function getCollectionTitle(collection?: CollectionItem): string +export function getCollectionTitle(collection?: CollectionItem, useTimestamp?: boolean): string { - return collection?.title - || new Date(collection?.timestamp ?? Date.now()) - .toLocaleDateString(browser.i18n.getUILanguage(), { year: "numeric", month: "short", day: "numeric" }); + if (collection?.title !== undefined && useTimestamp !== true) + return collection.title; + + return new Date(collection?.timestamp ?? Date.now()) + .toLocaleDateString(browser.i18n.getUILanguage(), { year: "numeric", month: "short", day: "numeric" }); }