diff --git a/app/models.py b/app/models.py index bb8dadc..8f2a287 100644 --- a/app/models.py +++ b/app/models.py @@ -165,7 +165,7 @@ class Notes(Base): ERROR(f"get_track({note_id}): not found") return None - def update_note( + def update( self, session: Session, row: int, text: Optional[str] = None) -> None: """ diff --git a/app/playlists.py b/app/playlists.py index 7c0a667..34a7b62 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -529,6 +529,9 @@ class PlaylistTab(QTableWidget): note: Notes = self._get_row_notes_object(row, session) session.add(note) playlist_notes[note.id] = note + if row != note.row: + DEBUG(f"Updating: {playlist.name=}, {row=}, {note.row=}") + note.update(session=session, row=row) # Database for note in playlist.notes: @@ -554,7 +557,7 @@ class PlaylistTab(QTableWidget): f"from {database_notes[note_id]=} " f"to {playlist_notes[note_id]=}" ) - database_notes[note_id].update_note( + database_notes[note_id].update( session, row=playlist_notes[note_id].row) # Tracks @@ -915,9 +918,8 @@ class PlaylistTab(QTableWidget): with Session() as session: if row in self._get_notes_rows(): # Save change to database - DEBUG(f"Notes.update_note: saving new note text '{new_text=}'") note: Notes = self._get_row_notes_object(row, session) - note.update_note(session, row, new_text) + note.update(session, row, new_text) # Set/clear row start time accordingly start_time = self._get_note_text_time(new_text) if start_time: