diff --git a/app/playlists.py b/app/playlists.py index 06193ba..e923293 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -718,19 +718,16 @@ class PlaylistTab(QTableWidget): def save_playlist(self, session: Session) -> None: """ - Save playlist to database + All playlist rows have a PlaylistRows id. Check that that id points + to this playlist (in case track has been moved from other) and that + the row number is correct (in case tracks have been reordered). """ - # Iteratate through playlist and check that the row in each - # playlist_row object is correct for row in range(self.rowCount()): plr = session.get(PlaylistRows, self._get_playlistrow_id(row)) - # Set the row number (even if it's already correct) - if plr.row_number != row: - log.debug( - f"Updating PlaylistRow: {plr.row_number=}, {row=}" - ) - plr.row_number = row + # Set the row number and playlist id (even if correct) + plr.row_number = row + plr.playlist_id = self.playlist_id # Any rows in the database with a row_number higher that the # current value of 'row' should not be there. Commit session