Add debug logging for note deletion

This commit is contained in:
drelich
2026-03-17 00:19:45 +01:00
parent d09920850d
commit 42cc1ffcd9
2 changed files with 13 additions and 2 deletions

View File

@@ -147,11 +147,20 @@ function App() {
}; };
const handleDeleteNote = async (note: Note) => { const handleDeleteNote = async (note: Note) => {
if (!api) return; console.log('handleDeleteNote called for note:', note.id, note.title);
if (!confirm(`Delete "${note.title}"?`)) return; if (!api) {
console.log('No API instance');
return;
}
const confirmed = confirm(`Delete "${note.title}"?`);
console.log('User confirmed deletion:', confirmed);
if (!confirmed) return;
try { try {
console.log('Calling API deleteNote...');
await api.deleteNote(note.id); await api.deleteNote(note.id);
console.log('Note deleted successfully, updating state...');
setNotes(notes.filter(n => n.id !== note.id)); setNotes(notes.filter(n => n.id !== note.id));
if (selectedNoteId === note.id) { if (selectedNoteId === note.id) {
setSelectedNoteId(notes[0]?.id || null); setSelectedNoteId(notes[0]?.id || null);

View File

@@ -146,7 +146,9 @@ export function NotesList({
</div> </div>
<button <button
onClick={(e) => { onClick={(e) => {
console.log('Delete button clicked for note:', note.id);
e.stopPropagation(); e.stopPropagation();
console.log('Calling onDeleteNote...');
onDeleteNote(note); onDeleteNote(note);
}} }}
className="ml-2 p-1 hover:bg-red-100 dark:hover:bg-red-900/30 rounded text-red-600 dark:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity" className="ml-2 p-1 hover:bg-red-100 dark:hover:bg-red-900/30 rounded text-red-600 dark:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity"