diff --git a/backend/app/sync/playlists.py b/backend/app/sync/playlists.py index 764ad7d..bb60489 100644 --- a/backend/app/sync/playlists.py +++ b/backend/app/sync/playlists.py @@ -43,8 +43,11 @@ def recompute_dirty(db: Session, pl: Playlist) -> None: (and Watch later) are never dirty; a missing baseline counts as dirty (unknown YT state).""" if not pl.yt_playlist_id: pl.dirty = False - else: - pl.dirty = pl.synced_fingerprint != current_fingerprint(db, pl) + return + # The session has autoflush off, so the caller's pending item/order/name edits aren't + # visible to current_fingerprint's query yet — flush first or dirty would lag one edit. + db.flush() + pl.dirty = pl.synced_fingerprint != current_fingerprint(db, pl) def _ensure_videos(db: Session, yt: YouTubeClient, video_ids: list[str]) -> None: