relatica/lib/riverpod_controllers/interactions_details_servic...

40 wiersze
1.4 KiB
Dart
Czysty Zwykły widok Historia

import 'package:logging/logging.dart';
import 'package:relatica/riverpod_controllers/rp_provider_extension.dart';
import 'package:result_monad/result_monad.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../friendica_client/friendica_client.dart';
import '../models/auth/profile.dart';
import '../models/connection.dart';
import '../models/exec_error.dart';
part 'interactions_details_services.g.dart';
const _cacheDuration = Duration(minutes: 5);
final _likesLogger = Logger('LikesForStatusProvider');
final _resharesLogger = Logger('ResharesForStatusProvider');
@riverpod
Future<Result<List<Connection>, ExecError>> likesForStatus(
LikesForStatusRef ref, Profile profile, String statusId) async {
2024-11-26 22:12:43 +00:00
_likesLogger.fine('Creating provider for $statusId for Profile $profile');
ref.cacheFor(_cacheDuration);
final likesResult = await InteractionsClient(profile).getLikes(statusId);
2024-11-26 22:12:43 +00:00
_likesLogger.fine('Values received for $statusId for Profile $profile');
return likesResult;
}
@riverpod
Future<Result<List<Connection>, ExecError>> resharesForStatus(
ResharesForStatusRef ref, Profile profile, String statusId) async {
ref.cacheFor(_cacheDuration);
2024-11-26 22:12:43 +00:00
_resharesLogger.fine('Creating provider for $statusId for Profile $profile');
final resharesResult =
await InteractionsClient(profile).getReshares(statusId);
2024-11-26 22:12:43 +00:00
_resharesLogger.fine('Values received for $statusId for Profile $profile');
return resharesResult;
}