mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-08-05 18:48:38 +02:00
refactor(library): drop unwired DB pagination providers
This commit is contained in:
@@ -1860,37 +1860,6 @@ final downloadHistoryProvider =
|
||||
DownloadHistoryNotifier.new,
|
||||
);
|
||||
|
||||
class DownloadHistoryPageRequest {
|
||||
final int limit;
|
||||
final int offset;
|
||||
|
||||
const DownloadHistoryPageRequest({this.limit = 100, this.offset = 0});
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
other is DownloadHistoryPageRequest &&
|
||||
other.limit == limit &&
|
||||
other.offset == offset;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(limit, offset);
|
||||
}
|
||||
|
||||
final downloadHistoryPageProvider = FutureProvider.autoDispose
|
||||
.family<List<DownloadHistoryItem>, DownloadHistoryPageRequest>((
|
||||
ref,
|
||||
request,
|
||||
) async {
|
||||
ref.watch(
|
||||
downloadHistoryProvider.select((state) => state.loadedIndexVersion),
|
||||
);
|
||||
final rows = await HistoryDatabase.instance.getAll(
|
||||
limit: request.limit,
|
||||
offset: request.offset,
|
||||
);
|
||||
return rows.map(DownloadHistoryItem.fromJson).toList(growable: false);
|
||||
});
|
||||
|
||||
class DownloadHistoryGroupedCounts {
|
||||
final int albumCount;
|
||||
final int singleTrackCount;
|
||||
|
||||
@@ -1044,80 +1044,3 @@ final localLibraryFirstCoverProvider = FutureProvider.autoDispose
|
||||
return null;
|
||||
});
|
||||
|
||||
final localLibraryPageProvider = FutureProvider.autoDispose
|
||||
.family<List<LocalLibraryItem>, LocalLibraryPageRequest>((
|
||||
ref,
|
||||
request,
|
||||
) async {
|
||||
ref.watch(
|
||||
localLibraryProvider.select((state) => state.loadedIndexVersion),
|
||||
);
|
||||
final rows = await LibraryDatabase.instance.getPage(request);
|
||||
return rows.map(LocalLibraryItem.fromJson).toList(growable: false);
|
||||
});
|
||||
|
||||
final localLibraryPageCountProvider = FutureProvider.autoDispose
|
||||
.family<int, LocalLibraryPageRequest>((ref, request) async {
|
||||
ref.watch(
|
||||
localLibraryProvider.select((state) => state.loadedIndexVersion),
|
||||
);
|
||||
return LibraryDatabase.instance.getPageCount(request);
|
||||
});
|
||||
|
||||
class LocalLibraryAlbumPageRequest {
|
||||
final int limit;
|
||||
final int offset;
|
||||
final LocalLibraryFilterMode filterMode;
|
||||
final LocalLibrarySortMode sortMode;
|
||||
final String? searchQuery;
|
||||
|
||||
const LocalLibraryAlbumPageRequest({
|
||||
this.limit = 100,
|
||||
this.offset = 0,
|
||||
this.filterMode = LocalLibraryFilterMode.albums,
|
||||
this.sortMode = LocalLibrarySortMode.album,
|
||||
this.searchQuery,
|
||||
});
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is LocalLibraryAlbumPageRequest &&
|
||||
other.limit == limit &&
|
||||
other.offset == offset &&
|
||||
other.filterMode == filterMode &&
|
||||
other.sortMode == sortMode &&
|
||||
other.searchQuery == searchQuery;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(limit, offset, filterMode, sortMode, searchQuery);
|
||||
}
|
||||
|
||||
final localLibraryAlbumPageProvider = FutureProvider.autoDispose
|
||||
.family<List<LocalLibraryAlbumGroup>, LocalLibraryAlbumPageRequest>((
|
||||
ref,
|
||||
request,
|
||||
) async {
|
||||
ref.watch(
|
||||
localLibraryProvider.select((state) => state.loadedIndexVersion),
|
||||
);
|
||||
return LibraryDatabase.instance.getAlbumPage(
|
||||
limit: request.limit,
|
||||
offset: request.offset,
|
||||
filterMode: request.filterMode,
|
||||
sortMode: request.sortMode,
|
||||
searchQuery: request.searchQuery,
|
||||
);
|
||||
});
|
||||
|
||||
final localLibraryAlbumCountProvider = FutureProvider.autoDispose
|
||||
.family<int, LocalLibraryAlbumPageRequest>((ref, request) async {
|
||||
ref.watch(
|
||||
localLibraryProvider.select((state) => state.loadedIndexVersion),
|
||||
);
|
||||
return LibraryDatabase.instance.getAlbumCount(
|
||||
filterMode: request.filterMode,
|
||||
searchQuery: request.searchQuery,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user