2024-11-26 22:10:51 +00:00
|
|
|
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');
|
2024-11-26 22:10:51 +00:00
|
|
|
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');
|
2024-11-26 22:10:51 +00:00
|
|
|
|
|
|
|
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');
|
2024-11-26 22:10:51 +00:00
|
|
|
|
|
|
|
final resharesResult =
|
|
|
|
await InteractionsClient(profile).getReshares(statusId);
|
2024-11-26 22:12:43 +00:00
|
|
|
_resharesLogger.fine('Values received for $statusId for Profile $profile');
|
2024-11-26 22:10:51 +00:00
|
|
|
|
|
|
|
return resharesResult;
|
|
|
|
}
|