Skip to content

Commit

Permalink
rename dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbach committed May 18, 2024
1 parent c83bce1 commit 838b253
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/renderer/history/history-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Badge, DropdownMenu, IconButton, Tooltip } from "@radix-ui/themes";
import {
HiArrowTopRightOnSquare,
HiMiniBars3,
HiMiniPencilSquare,
HiOutlineCog8Tooth,
HiOutlineDocumentText,
HiOutlineFolderOpen,
Expand All @@ -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 = ({
Expand Down Expand Up @@ -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 (
Expand All @@ -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 (
Expand Down Expand Up @@ -144,6 +157,9 @@ export const HistoryItem: FC<{
>
<HiArrowTopRightOnSquare /> Open Recording
</DropdownMenu.Item>
<DropdownMenu.Item onClick={rename}>
<HiMiniPencilSquare /> Rename
</DropdownMenu.Item>
<DropdownMenu.Item
onClick={() =>
historyApi.updateRecordingMeta(id, {
Expand Down

0 comments on commit 838b253

Please sign in to comment.