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

@ -24,6 +24,7 @@ import '../state/trust_cubit.dart';
import 'market_gate.dart';
import 'peer_avatar.dart';
import 'rating_sheet.dart';
import 'report_sheet.dart';
import 'theme.dart';
/// A 1:1 encrypted chat with one peer (redesign screen 10). Private and
@ -202,6 +203,20 @@ class _ChatScreenState extends State<ChatScreen> {
widget.settings ??
(getIt.isRegistered<SocialSettings>() ? getIt<SocialSettings>() : null);
/// Reports this peer (a standard report event to the community servers);
/// when they were also blocked from the sheet, leaves the chat too.
Future<void> _reportPeer() async {
final outcome = await showReportSheet(
context,
connection: widget.connection,
subjectPubkey: widget.peerPubkey,
settings: _settings,
);
if (outcome != null && outcome.blocked && mounted) {
Navigator.of(context).pop();
}
}
/// Blocks this peer after confirmation and leaves the chat; their offers,
/// conversation and future messages disappear (all locally).
Future<void> _blockPeer() async {
@ -287,19 +302,24 @@ class _ChatScreenState extends State<ChatScreen> {
tooltip: t.chat.payG1,
onPressed: _payG1,
),
if (_settings != null)
PopupMenuButton<String>(
key: const Key('chat.menu'),
onSelected: (value) {
if (value == 'block') _blockPeer();
},
itemBuilder: (context) => [
PopupMenuButton<String>(
key: const Key('chat.menu'),
onSelected: (value) {
if (value == 'report') _reportPeer();
if (value == 'block') _blockPeer();
},
itemBuilder: (context) => [
PopupMenuItem(
value: 'report',
child: Text(t.report.person),
),
if (_settings != null)
PopupMenuItem(
value: 'block',
child: Text(t.block.action),
),
],
),
],
),
],
),
body: _loading || messages == null || trust == null || rating == null