27 lines
741 B
Dart
27 lines
741 B
Dart
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
|
|
|
||
|
|
import '../core/contracts/library.dart';
|
||
|
|
import '../core/domain/ports/emby_gateway.dart';
|
||
|
|
import 'di_providers.dart';
|
||
|
|
import 'session_provider.dart';
|
||
|
|
|
||
|
|
|
||
|
|
final serverItemCountsProvider = FutureProvider.family<ItemCountsRes?, String>((
|
||
|
|
ref,
|
||
|
|
serverId,
|
||
|
|
) async {
|
||
|
|
final sessions = ref.watch(sessionProvider);
|
||
|
|
final session = sessions.value?.sessions
|
||
|
|
.where((s) => s.serverId == serverId)
|
||
|
|
.firstOrNull;
|
||
|
|
if (session == null) return null;
|
||
|
|
|
||
|
|
final gateway = await ref.read(embyGatewayProvider.future);
|
||
|
|
final ctx = AuthedRequestContext(
|
||
|
|
baseUrl: session.serverUrl,
|
||
|
|
token: session.token,
|
||
|
|
userId: session.userId,
|
||
|
|
);
|
||
|
|
return gateway.getItemCounts(ctx);
|
||
|
|
});
|