Fix Playlist song list updating

When updating the song list in a playlist, we get a list of additions and
removals (in the form of table indexes) to do. We then need to do the removals
first to avoid invalidating the table indexes. The previous code did the
additions first, causing exceptions and bogus songs left in the UI.
This commit is contained in:
Matt Corallo
2022-04-11 21:09:47 +00:00
parent efe038d36c
commit e8913d552d

View File

@@ -148,13 +148,13 @@ def diff_song_store(store_to_edit: Any, new_store: Iterable[Any]):
idx, field = _parse_diff_location(edit_location)
store_to_edit[int(idx)][int(field)] = diff["new_value"]
for _, value in added.items():
store_to_edit.append(value)
for remove_location, _ in reversed(list(removed.items())):
remove_at = int(_parse_diff_location(remove_location)[0])
del store_to_edit[remove_at]
for _, value in added.items():
store_to_edit.append(value)
def diff_model_store(store_to_edit: Any, new_store: Iterable[Any]):
"""