mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-24 10:30:43 +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.
21 lines
743 B
Dart
21 lines
743 B
Dart
import 'package:spotiflac_android/models/track.dart';
|
|
import 'package:spotiflac_android/providers/download_history_provider.dart';
|
|
import 'package:spotiflac_android/services/history_database.dart';
|
|
|
|
/// Retains derived lookups while the immutable source list is unchanged.
|
|
/// Callers replace their list for metadata, order, or filter changes.
|
|
class TrackHistorySnapshot {
|
|
List<Track>? _source;
|
|
HistoryBatchLookupRequest request = HistoryBatchLookupRequest.snapshot([]);
|
|
|
|
List<HistoryLookupRequest> get lookups => request.tracks;
|
|
|
|
void update(List<Track> tracks) {
|
|
if (identical(tracks, _source)) return;
|
|
_source = tracks;
|
|
request = HistoryBatchLookupRequest.snapshot(
|
|
tracks.map(historyLookupForTrack),
|
|
);
|
|
}
|
|
}
|