fix(playlists): dirty lagged one edit (flush before fingerprinting)

The session has autoflush off, so recompute_dirty's query read the last-committed
state, not the current request's pending item/order edits — so the first reorder
after a sync compared against itself and missed dirty, and only the next edit showed
it. Flush pending changes before computing the current fingerprint. Verified: a swap
now flips dirty immediately, and reverting to the original clears it.
This commit is contained in:
npeter83 2026-06-16 00:11:58 +02:00
parent 871dad834a
commit 7b8f835226

View file

@ -43,7 +43,10 @@ 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:
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)