From 838b253a631e09bd33ea98fa7c909f5c5b5e8069 Mon Sep 17 00:00:00 2001 From: Lukas Bach Date: Sun, 19 May 2024 01:37:12 +0200 Subject: [PATCH] rename dialog --- src/renderer/history/history-item.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/renderer/history/history-item.tsx b/src/renderer/history/history-item.tsx index 6537fea..4982e9f 100644 --- a/src/renderer/history/history-item.tsx +++ b/src/renderer/history/history-item.tsx @@ -3,6 +3,7 @@ import { Badge, DropdownMenu, IconButton, Tooltip } from "@radix-ui/themes"; import { HiArrowTopRightOnSquare, HiMiniBars3, + HiMiniPencilSquare, HiOutlineCog8Tooth, HiOutlineDocumentText, HiOutlineFolderOpen, @@ -18,7 +19,7 @@ import { PostProcessingStep, RecordingMeta } from "../../types"; import { historyApi } from "../api"; import { ListItem } from "../common/list-item"; import { EntityTitle } from "../common/entity-title"; -import { useWindowedConfirm } from "../dialog/context"; +import { useWindowedConfirm, useWindowedPromptText } from "../dialog/context"; import { HistoryItemIcon } from "./history-item-icon"; const getSubtitle = ({ @@ -55,6 +56,11 @@ export const HistoryItem: FC<{ "Delete recording", "Are you sure you want to delete this recording?", ); + const promptRename = useWindowedPromptText( + "Rename recording", + "What should the name of the recording be?", + "Untitled Recording", + ); const isNewDate = useMemo(() => { if (!priorItemDate) return true; return ( @@ -74,6 +80,13 @@ export const HistoryItem: FC<{ [id], ); + const rename = useCallback(async () => { + const name = await promptRename(recording.name); + if (name) { + await historyApi.updateRecordingMeta(id, { name }); + } + }, [id]); + const duration = humanizer(recording.duration || 0, { maxDecimalPoints: 0 }); return ( @@ -144,6 +157,9 @@ export const HistoryItem: FC<{ > Open Recording + + Rename + historyApi.updateRecordingMeta(id, {