mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-29 07:18:49 +02:00
fix(playlists): keep imported playlist track order (#482)
Playlist tracks were read newest-first (added_at DESC, rowid DESC), so a batch import - inserted in playlist order with one timestamp - came back reversed, and the in-memory prepend matched that. Playlists now use insertion order: snapshot reads ASC, single adds append, and batch adds append in order. Existing rows were already stored in playlist order, so old libraries display correctly without migration. The preview-cover query follows the first visible track.
This commit is contained in:
@@ -803,7 +803,7 @@ class LibraryCollectionsNotifier extends Notifier<LibraryCollectionsState> {
|
||||
final changed = _replacePlaylistById(playlistId, (playlist) {
|
||||
if (playlist.containsTrackKey(key)) return playlist;
|
||||
return playlist.copyWith(
|
||||
tracks: [entry, ...playlist.tracks],
|
||||
tracks: [...playlist.tracks, entry],
|
||||
updatedAt: now,
|
||||
);
|
||||
});
|
||||
@@ -864,7 +864,8 @@ class LibraryCollectionsNotifier extends Notifier<LibraryCollectionsState> {
|
||||
);
|
||||
final changed = _replacePlaylistById(playlistId, (current) {
|
||||
return current.copyWith(
|
||||
tracks: [...entriesToAdd.reversed, ...current.tracks],
|
||||
// Append in playlist order, matching the ASC snapshot ordering.
|
||||
tracks: [...current.tracks, ...entriesToAdd],
|
||||
updatedAt: now,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user