Fix adding only a note from track dialog

Fixes #160
This commit is contained in:
Keith Edmunds 2023-01-16 17:20:18 +00:00
parent d87ff80bef
commit 0507f495ad
2 changed files with 11 additions and 6 deletions

View File

@ -1609,8 +1609,13 @@ class DbDialog(QDialog):
self.accept()
return
self.parent().visible_playlist_tab().insert_track(
self.session, track, note=self.ui.txtNote.text())
if track:
self.parent().visible_playlist_tab().insert_track(
self.session, track, note=self.ui.txtNote.text())
else:
self.parent().visible_playlist_tab().insert_header(
self.session, note=self.ui.txtNote.text())
# Save to database (which will also commit changes)
self.parent().visible_playlist_tab().save_playlist(self.session)
# Clear note field and select search text to make it easier for

View File

@ -669,7 +669,7 @@ class PlaylistTab(QTableWidget):
self.update_display(session)
def insert_track(self, session: scoped_session, track: Tracks,
note: str = None, repaint: bool = True) -> None:
note: Optional[str] = None, repaint: bool = True) -> None:
"""
Insert track into playlist tab.
@ -680,10 +680,10 @@ class PlaylistTab(QTableWidget):
to do the heavy lifing.
"""
if not track and track.id:
if not track:
log.debug(
f"insert_track({session=}, {track=}, {note=}, {repaint=}"
" called with either no track or no track.id"
f"insert_track({session=}, {note=}, {repaint=}"
" called with no track"
)
return