Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bot-code/src/notes/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def edit_note(notebook: Notebook, name):
editor.run()

if editor.saved_content is not None:
notebook.edit_note(note.name, editor.saved_content)
notebook.edit_note(note.id, editor.saved_content)
console.print(f"Note '{name}' updated successfully!", style="green")
else:
console.print(f"Note '{name}' edit cancelled.", style="yellow")
Expand All @@ -176,7 +176,12 @@ def delete_note(notebook: Notebook, name):
while not name:
name = input("Enter note name: ").strip()

success = notebook.delete_note(name)
note = notebook.get_note_by_name(name)
if not note:
console.print(f"Note '{name}' not found.", style="yellow")
return

success = notebook.delete_note(note.id)
if success:
console.print(f"Note '{name}' deleted successfully.", style="green")
else:
Expand Down
7 changes: 5 additions & 2 deletions bot-code/src/notes/notes_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def action_save(self) -> None:

def action_quit(self) -> None:
editor = self.query_one(NoteEditor)
if (self.x_content == editor.get_text()):
changed = self.x_content != editor.get_text()
saved = self.saved_content != None and self.saved_content == editor.get_text()

if ((not changed) or (changed and saved)):
self.dismiss(self.saved_content)
return

Expand Down Expand Up @@ -248,7 +251,7 @@ async def action_edit(self, editable: bool):

def on_close(content: str):
if content:
self.notebook.edit_note(note.name, content)
self.notebook.edit_note(note.id, content)
self.list(self.notebook.notes)

screen = EditorScreen(note.name, note.content, editable, on_close=self.handle_editor_quit)
Expand Down