Skip to content

feat: add missing getPublicList#463

Merged
1-leo merged 6 commits intomasterfrom
feat/lists-getPublicList
Feb 25, 2026
Merged

feat: add missing getPublicList#463
1-leo merged 6 commits intomasterfrom
feat/lists-getPublicList

Conversation

@1-leo
Copy link
Contributor

@1-leo 1-leo commented Feb 23, 2026

adds:

  Future<Nip51List?> getPublicList({
    required int kind,
    required String publicKey,
    bool forceRefresh = false,
    Duration timeout = const Duration(seconds: 5),
  }) 
  

apparently we missed that

@1-leo 1-leo requested review from frnandu and nogringo February 23, 2026 13:56
@1-leo 1-leo self-assigned this Feb 23, 2026
@1-leo 1-leo added this to ndk-dev Feb 23, 2026
@1-leo 1-leo added the enhancement New feature or request label Feb 23, 2026
@1-leo 1-leo moved this to In Progress in ndk-dev Feb 23, 2026
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.90%. Comparing base (c2e6102) to head (ab4d779).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...ges/ndk/lib/domain_layer/usecases/lists/lists.dart 25.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #463      +/-   ##
==========================================
- Coverage   76.01%   75.90%   -0.12%     
==========================================
  Files         152      152              
  Lines        6204     6216      +12     
==========================================
+ Hits         4716     4718       +2     
- Misses       1488     1498      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

final signer = Bip340EventSigner(privateKey: null, publicKey: publicKey);

Nip51List? list =
!forceRefresh ? await _getCachedNip51List(kind, signer) : null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we refactor _getCachedNip51List to accept a pubkey as parameter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not easy because Nip51List.fromEvent has the signer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add the pubkey parameter and create the signer in _getCachedNip51List if it's not provided.

@1-leo 1-leo requested a review from nogringo February 23, 2026 14:31
Copy link
Collaborator

@nogringo nogringo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to refactor to wait all events and then sort them to save and return the newest.

@1-leo
Copy link
Contributor Author

1-leo commented Feb 23, 2026

We may need to refactor to wait all events and then sort them to save and return the newest.

what do you suggest? Saving all lists?

@nogringo
Copy link
Collaborator

what do you suggest? Saving all lists?

Future<Nip51List?> getPublicList({
  required int kind,
  required String publicKey,
  bool forceRefresh = false,
  Duration timeout = const Duration(seconds: 5),
}) async {
  final signer = Bip340EventSigner(privateKey: null, publicKey: publicKey);

  Nip51List? list =
      !forceRefresh ? await _getCachedNip51List(kind, signer) : null;

  if (list != null) return list;

  final events = await _requests.query(filters: [
    Filter(
      authors: [publicKey],
      kinds: [kind],
      limit: 1,
    )
  ], timeout: timeout).future;

  if (events.isEmpty) return null;

  events.sort((a, b) => a.createdAt.compareTo(b.createdAt));

  await _cacheManager.saveEvent(events.last);
  return await Nip51List.fromEvent(events.last, signer);
}

and we can use await _cacheManager.saveEvents(events); or await _cacheManager.saveEvent(events.last);

@1-leo 1-leo requested a review from nogringo February 24, 2026 09:20
@1-leo 1-leo merged commit 15cb684 into master Feb 25, 2026
5 of 7 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in ndk-dev Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants