mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:spotube/models/metadata/metadata.dart';
|
|
import 'package:spotube/provider/metadata_plugin/metadata_plugin_provider.dart';
|
|
import 'package:spotube/provider/metadata_plugin/utils/common.dart';
|
|
import 'package:spotube/provider/metadata_plugin/utils/family_paginated.dart';
|
|
|
|
class MetadataPluginSearchArtistsNotifier
|
|
extends AutoDisposeFamilyPaginatedAsyncNotifier<SpotubeFullArtistObject,
|
|
String> {
|
|
MetadataPluginSearchArtistsNotifier() : super();
|
|
|
|
@override
|
|
fetch(offset, limit) async {
|
|
if (arg.isEmpty) {
|
|
return SpotubePaginationResponseObject<SpotubeFullArtistObject>(
|
|
limit: limit,
|
|
nextOffset: null,
|
|
total: 0,
|
|
items: [],
|
|
hasMore: false,
|
|
);
|
|
}
|
|
|
|
final res = await (await metadataPlugin).search.artists(
|
|
arg,
|
|
offset: offset,
|
|
limit: limit,
|
|
);
|
|
|
|
return res;
|
|
}
|
|
|
|
@override
|
|
build(arg) async {
|
|
ref.cacheFor();
|
|
|
|
ref.watch(metadataPluginProvider);
|
|
return await fetch(0, 20);
|
|
}
|
|
}
|
|
|
|
final metadataPluginSearchArtistsProvider =
|
|
AutoDisposeAsyncNotifierProviderFamily<MetadataPluginSearchArtistsNotifier,
|
|
SpotubePaginationResponseObject<SpotubeFullArtistObject>, String>(
|
|
() => MetadataPluginSearchArtistsNotifier(),
|
|
);
|