mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-02-04 07:52:55 +00:00
35 lines
1.0 KiB
Dart
35 lines
1.0 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:spotube/models/metadata/metadata.dart';
|
|
import 'package:spotube/provider/metadata_plugin/core/auth.dart';
|
|
import 'package:spotube/provider/metadata_plugin/utils/paginated.dart';
|
|
|
|
class MetadataPluginBrowseSectionsNotifier
|
|
extends PaginatedAsyncNotifier<SpotubeBrowseSectionObject> {
|
|
@override
|
|
Future<SpotubeFlattenedPaginationObject<SpotubeBrowseSectionObject>> fetch(
|
|
int offset,
|
|
int limit,
|
|
) async {
|
|
return await (await metadataPlugin)
|
|
.browse
|
|
.sections(
|
|
limit: limit,
|
|
offset: offset,
|
|
mpscTx: await mpscTx,
|
|
)
|
|
.then((value) => value.flatten());
|
|
}
|
|
|
|
@override
|
|
build() async {
|
|
ref.watch(metadataPluginAuthenticatedProvider);
|
|
return await fetch(0, 20);
|
|
}
|
|
}
|
|
|
|
final metadataPluginBrowseSectionsProvider = AsyncNotifierProvider<
|
|
MetadataPluginBrowseSectionsNotifier,
|
|
SpotubeFlattenedPaginationObject<SpotubeBrowseSectionObject>>(
|
|
() => MetadataPluginBrowseSectionsNotifier(),
|
|
);
|