From 91a629add18394edd084c7cc50bc2708d2387307 Mon Sep 17 00:00:00 2001 From: LeoLox <58687994+leo-lox@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:09:35 +0100 Subject: [PATCH] usecase, provider --- .../nostr_list_repository_impl.dart | 2 -- .../usecases/get_nostr_lists.dart | 20 +++++++++++++++++ .../providers/nostr_list_provider.dart | 22 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 lib/domain_layer/usecases/get_nostr_lists.dart create mode 100644 lib/presentation_layer/providers/nostr_list_provider.dart diff --git a/lib/data_layer/repositories/nostr_list_repository_impl.dart b/lib/data_layer/repositories/nostr_list_repository_impl.dart index 316aae1..092a030 100644 --- a/lib/data_layer/repositories/nostr_list_repository_impl.dart +++ b/lib/data_layer/repositories/nostr_list_repository_impl.dart @@ -9,11 +9,9 @@ import '../models/nostr_lists_model.dart'; class NostrListRepositoryImpl implements NostrListRepository { final DartNdkSource dartNdkSource; - final ndk.EventVerifier eventVerifier; NostrListRepositoryImpl({ required this.dartNdkSource, - required this.eventVerifier, }); @override diff --git a/lib/domain_layer/usecases/get_nostr_lists.dart b/lib/domain_layer/usecases/get_nostr_lists.dart new file mode 100644 index 0000000..15945c7 --- /dev/null +++ b/lib/domain_layer/usecases/get_nostr_lists.dart @@ -0,0 +1,20 @@ +import '../entities/nostr_list.dart'; +import '../repositories/nostr_list_repository.dart'; + +class GetNostrLists { + final NostrListRepository _nostrListRepository; + + GetNostrLists({ + required NostrListRepository nostrListRepository, + }) : _nostrListRepository = nostrListRepository; + + Future getPublicNostrFollowSet({ + required String pubKey, + required String name, + }) { + return _nostrListRepository.getPublicNostrFollowSet( + pubKey: pubKey, + name: name, + ); + } +} diff --git a/lib/presentation_layer/providers/nostr_list_provider.dart b/lib/presentation_layer/providers/nostr_list_provider.dart new file mode 100644 index 0000000..dcaa825 --- /dev/null +++ b/lib/presentation_layer/providers/nostr_list_provider.dart @@ -0,0 +1,22 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../data_layer/data_sources/dart_ndk_source.dart'; +import '../../data_layer/repositories/nostr_list_repository_impl.dart'; +import '../../domain_layer/repositories/nostr_list_repository.dart'; +import '../../domain_layer/usecases/get_nostr_lists.dart'; + +import 'ndk_provider.dart'; + +final nostrListProvider = Provider((ref) { + final ndk = ref.watch(ndkProvider); + + final DartNdkSource dartNdkSource = DartNdkSource(ndk); + + final NostrListRepository listsRepo = NostrListRepositoryImpl( + dartNdkSource: dartNdkSource, + ); + + final GetNostrLists getLists = GetNostrLists(nostrListRepository: listsRepo); + + return getLists; +});