feat(social): standard NIP-56 reporting — ReportTransport in commons_core, report sheet on offers and chats, local hide + optional block

This commit is contained in:
vjrj 2026-07-13 07:56:43 +02:00
parent 11b242edbf
commit 0e7faaeb90
15 changed files with 560 additions and 15 deletions

View file

@ -22,6 +22,7 @@ class OffersState extends Equatable {
this.categoryFilter = const {},
this.organicOnly = false,
this.blockedAuthors = const {},
this.hiddenOfferKeys = const {},
this.searching = false,
this.publishing = false,
this.hasSearched = false,
@ -51,6 +52,10 @@ class OffersState extends Equatable {
/// already discovered.
final Set<String> blockedAuthors;
/// Individual offers this user reported and hid ("author:id" keys, see
/// SocialSettings.offerKey). Same idea as [blockedAuthors], finer grain.
final Set<String> hiddenOfferKeys;
final bool searching;
final bool publishing;
@ -67,6 +72,9 @@ class OffersState extends Equatable {
final q = query.trim().toLowerCase();
return offers.where((o) {
if (blockedAuthors.contains(o.authorPubkeyHex)) return false;
if (hiddenOfferKeys.contains('${o.authorPubkeyHex}:${o.id}')) {
return false;
}
if (q.isNotEmpty && !o.summary.toLowerCase().contains(q)) return false;
if (typeFilter.isNotEmpty && !typeFilter.contains(o.type)) return false;
if (categoryFilter.isNotEmpty &&
@ -104,6 +112,7 @@ class OffersState extends Equatable {
Set<String>? categoryFilter,
bool? organicOnly,
Set<String>? blockedAuthors,
Set<String>? hiddenOfferKeys,
bool? searching,
bool? publishing,
bool? hasSearched,
@ -117,6 +126,7 @@ class OffersState extends Equatable {
categoryFilter: categoryFilter ?? this.categoryFilter,
organicOnly: organicOnly ?? this.organicOnly,
blockedAuthors: blockedAuthors ?? this.blockedAuthors,
hiddenOfferKeys: hiddenOfferKeys ?? this.hiddenOfferKeys,
searching: searching ?? this.searching,
publishing: publishing ?? this.publishing,
hasSearched: hasSearched ?? this.hasSearched,
@ -133,6 +143,7 @@ class OffersState extends Equatable {
categoryFilter,
organicOnly,
blockedAuthors,
hiddenOfferKeys,
searching,
publishing,
hasSearched,
@ -191,6 +202,7 @@ class OffersCubit extends Cubit<OffersState> {
categoryFilter: state.categoryFilter,
organicOnly: state.organicOnly,
blockedAuthors: state.blockedAuthors,
hiddenOfferKeys: state.hiddenOfferKeys,
searching: true,
hasSearched: true,
));
@ -250,6 +262,10 @@ class OffersCubit extends Cubit<OffersState> {
void setBlockedAuthors(Set<String> pubkeys) =>
emit(state.copyWith(blockedAuthors: pubkeys));
/// Replaces the set of locally hidden (reported) offers.
void setHiddenOffers(Set<String> offerKeys) =>
emit(state.copyWith(hiddenOfferKeys: offerKeys));
/// Clears every chip filter (leaves the text search untouched).
void clearFilters() => emit(state.copyWith(
typeFilter: const {},