Fix model deletion

This commit is contained in:
Gregory Schier
2025-05-21 08:25:12 -07:00
parent c2f9760d08
commit d8b1cadae6
3 changed files with 5 additions and 11 deletions

View File

@@ -174,15 +174,12 @@ const BaseInput = forwardRef<EditorView, InputProps>(function InputBase(
);
const isValid = useMemo(() => {
console.log('CHECKING VALIDITY', validate);
if (required && !validateRequire(defaultValue ?? '')) return false;
if (typeof validate === 'boolean') return validate;
if (typeof validate === 'function' && !validate(defaultValue ?? '')) return false;
return true;
}, [required, defaultValue, validate]);
console.log('IS VALID', isValid, defaultValue);
const handleChange = useCallback(
(value: string) => {
onChange?.(value);

View File

@@ -1,9 +1,4 @@
import {
deleteModelById,
duplicateModelById,
getModel,
workspacesAtom,
} from '@yaakapp-internal/models';
import { duplicateModelById, getModel, workspacesAtom } from '@yaakapp-internal/models';
import { useAtomValue } from 'jotai';
import React, { useMemo } from 'react';
import { useCreateDropdownItems } from '../../hooks/useCreateDropdownItems';
@@ -134,7 +129,9 @@ export function SidebarItemContextMenu({ child, show, close }: Props) {
hotKeyAction: 'sidebar.delete_selected_item',
hotKeyLabelOnly: true,
leftSlot: <Icon icon="trash" />,
onSelect: async () => deleteModelById(child.model, child.id),
onSelect: async () => {
await deleteModelWithConfirm(getModel(child.model, child.id));
},
},
];
}

View File

@@ -11,7 +11,7 @@ export async function deleteModelWithConfirm(model: AnyModel | null): Promise<bo
}
const confirmed = await showConfirmDelete({
id: 'delete-model-' + model.model,
id: 'delete-model-' + model.id,
title: 'Delete ' + modelTypeLabel(model),
description: (
<>