mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-13 21:38:58 +02:00
Share the retained history lookup snapshot across albums, playlists, artists, home search results, and library folders. Reuse derived lookups until the track list is replaced. Test reuse with 4,000 items and invalidation after replacement, sorting, and filtering.
23 lines
965 B
Dart
23 lines
965 B
Dart
import 'package:spotiflac_android/models/track.dart';
|
|
import 'package:spotiflac_android/screens/track_history_snapshot.dart';
|
|
import 'package:spotiflac_android/providers/library_collections_provider.dart';
|
|
import 'package:spotiflac_android/services/history_database.dart';
|
|
|
|
/// Collection providers replace their track list when its contents change.
|
|
/// Keep derived data across selection/layout rebuilds of the same snapshot.
|
|
class LibraryTracksFolderData {
|
|
List<CollectionTrackEntry>? _entries;
|
|
Set<String> keys = const {};
|
|
List<Track> tracks = const [];
|
|
final _history = TrackHistorySnapshot();
|
|
HistoryBatchLookupRequest get historyRequest => _history.request;
|
|
|
|
void update(List<CollectionTrackEntry> entries) {
|
|
if (identical(entries, _entries)) return;
|
|
_entries = entries;
|
|
keys = Set.unmodifiable(entries.map((entry) => entry.key));
|
|
tracks = List.unmodifiable(entries.map((entry) => entry.track));
|
|
_history.update(tracks);
|
|
}
|
|
}
|