1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-21 20:39:22 +00:00

Can report conversation message

This commit is contained in:
Pierre HUBERT 2022-03-18 19:21:08 +01:00
parent 1bd7840be6
commit 79ed8e934e
4 changed files with 27 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:comunic/enums/report_target_type.dart';
import 'package:comunic/helpers/conversations_helper.dart';
import 'package:comunic/helpers/events_helper.dart';
import 'package:comunic/helpers/server_config_helper.dart';
@ -11,7 +12,9 @@ import 'package:comunic/models/config.dart';
import 'package:comunic/models/conversation.dart';
import 'package:comunic/models/conversation_message.dart';
import 'package:comunic/models/new_conversation_message.dart';
import 'package:comunic/models/report_target.dart';
import 'package:comunic/ui/dialogs/pick_file_dialog.dart';
import 'package:comunic/ui/dialogs/report_dialog.dart';
import 'package:comunic/ui/routes/main_route/main_route.dart';
import 'package:comunic/ui/tiles/conversation_message_tile.dart';
import 'package:comunic/ui/tiles/server_conversation_message_tile.dart';
@ -504,6 +507,7 @@ class _ConversationScreenState extends SafeState<ConversationScreen> {
onRequestMessageStats: _requestMessageStats,
onRequestMessageUpdate: _updateMessage,
onRequestMessageDelete: _deleteMessage,
onReportMessage: _reportMessage,
);
Widget _buildDateWidget(DateTime dt) => Center(
@ -753,4 +757,9 @@ class _ConversationScreenState extends SafeState<ConversationScreen> {
if (!await _conversationsHelper.deleteMessage(message.id))
showSimpleSnack(context, tr("Could not delete conversation message!")!);
}
/// Report message
void _reportMessage(ConversationMessage msg) => showReportDialog(
ctx: context,
target: ReportTarget(ReportTargetType.ConversationMessage, msg.id!));
}

View File

@ -115,7 +115,7 @@ class CommentTile extends StatelessWidget {
]..addAll(srvConfig!.isReportingEnabled && !comment.isOwner
? [
PopupMenuItem(
child: Text(tr("Report Abuse")!),
child: Text(tr("Report abuse")!),
value: _CommentAction.REPORT,
)
]

View File

@ -1,3 +1,4 @@
import 'package:comunic/helpers/server_config_helper.dart';
import 'package:comunic/models/conversation_message.dart';
import 'package:comunic/models/user.dart';
import 'package:comunic/ui/widgets/conversation_file_tile.dart';
@ -17,6 +18,7 @@ enum _MenuChoices {
DELETE,
REQUEST_UPDATE_CONTENT,
GET_STATS,
REPORT
}
typedef OnRequestMessageStats = void Function(ConversationMessage);
@ -29,6 +31,7 @@ class ConversationMessageTile extends StatelessWidget {
final OnRequestMessageStats onRequestMessageStats;
final OnRequestMessageUpdate onRequestMessageUpdate;
final OnRequestMessageDelete onRequestMessageDelete;
final Function(ConversationMessage) onReportMessage;
const ConversationMessageTile({
Key? key,
@ -37,6 +40,7 @@ class ConversationMessageTile extends StatelessWidget {
required this.onRequestMessageStats,
required this.onRequestMessageUpdate,
required this.onRequestMessageDelete,
required this.onReportMessage,
}) : super(key: key);
@override
@ -90,6 +94,14 @@ class ConversationMessageTile extends StatelessWidget {
value: _MenuChoices.DELETE,
child: Text(tr("Delete")!),
),
// Report the message
PopupMenuItem(
enabled:
srvConfig!.isReportingEnabled && !message.isOwner,
value: _MenuChoices.REPORT,
child: Text(tr("Report abuse")!),
),
]..removeWhere((element) => !element.enabled),
),
)
@ -133,6 +145,10 @@ class ConversationMessageTile extends StatelessWidget {
case _MenuChoices.DELETE:
onRequestMessageDelete(message);
break;
case _MenuChoices.REPORT:
onReportMessage(message);
break;
}
}
}

View File

@ -133,7 +133,7 @@ class ConversationTile extends StatelessWidget {
]..addAll(srvConfig!.isReportingEnabled
? [
PopupMenuItem(
child: Text(tr("Report")!),
child: Text(tr("Report abuse")!),
value: _PopupMenuChoices.REPORT,
)
]