mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-21 20:39:22 +00:00
Can report post
This commit is contained in:
parent
ec16984b8a
commit
20b19d0a4a
@ -6,6 +6,7 @@ import 'package:comunic/lists/comments_list.dart';
|
||||
import 'package:comunic/models/displayed_content.dart';
|
||||
import 'package:comunic/models/like_element.dart';
|
||||
import 'package:comunic/models/survey.dart';
|
||||
import 'package:comunic/utils/account_utils.dart' as account;
|
||||
|
||||
/// Single post information
|
||||
///
|
||||
@ -76,6 +77,8 @@ class Post implements LikeElement {
|
||||
access == UserAccessLevels.FULL ||
|
||||
access == UserAccessLevels.INTERMEDIATE;
|
||||
|
||||
bool get isOwner => userID == account.userID();
|
||||
|
||||
@override
|
||||
LikesType get likeType => LikesType.POST;
|
||||
}
|
||||
|
@ -2,15 +2,19 @@ import 'dart:math';
|
||||
|
||||
import 'package:comunic/enums/post_kind.dart';
|
||||
import 'package:comunic/enums/post_visibility_level.dart';
|
||||
import 'package:comunic/enums/report_target_type.dart';
|
||||
import 'package:comunic/helpers/comments_helper.dart';
|
||||
import 'package:comunic/helpers/posts_helper.dart';
|
||||
import 'package:comunic/helpers/server_config_helper.dart';
|
||||
import 'package:comunic/lists/groups_list.dart';
|
||||
import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/comment.dart';
|
||||
import 'package:comunic/models/new_comment.dart';
|
||||
import 'package:comunic/models/post.dart';
|
||||
import 'package:comunic/models/report_target.dart';
|
||||
import 'package:comunic/models/user.dart';
|
||||
import 'package:comunic/ui/dialogs/post_visibility_picker_dialog.dart';
|
||||
import 'package:comunic/ui/dialogs/report_dialog.dart';
|
||||
import 'package:comunic/ui/tiles/comment_tile.dart';
|
||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||||
import 'package:comunic/ui/widgets/countdown_widget.dart';
|
||||
@ -41,7 +45,7 @@ const TextStyle _userNameStyle = TextStyle(
|
||||
fontSize: 16.0);
|
||||
|
||||
/// Post actions
|
||||
enum _PostActions { DELETE, UPDATE_CONTENT }
|
||||
enum _PostActions { DELETE, UPDATE_CONTENT, REPORT }
|
||||
|
||||
class PostTile extends StatefulWidget {
|
||||
final Post post;
|
||||
@ -152,7 +156,14 @@ class _PostTileState extends State<PostTile> {
|
||||
value: _PostActions.DELETE,
|
||||
enabled: widget.post.canDelete,
|
||||
),
|
||||
],
|
||||
]..addAll(srvConfig!.isReportingEnabled && !widget.post.isOwner
|
||||
? [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Report abuse")!),
|
||||
value: _PostActions.REPORT,
|
||||
)
|
||||
]
|
||||
: []),
|
||||
onSelected: _selectedPostMenuAction,
|
||||
)
|
||||
],
|
||||
@ -561,6 +572,11 @@ class _PostTileState extends State<PostTile> {
|
||||
case _PostActions.DELETE:
|
||||
confirmDelete();
|
||||
break;
|
||||
|
||||
// Report content
|
||||
case _PostActions.REPORT:
|
||||
reportContent();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,4 +636,9 @@ class _PostTileState extends State<PostTile> {
|
||||
|
||||
widget.onDeletedPost(widget.post);
|
||||
}
|
||||
|
||||
/// Report post
|
||||
void reportContent() async => await showReportDialog(
|
||||
ctx: context,
|
||||
target: ReportTarget(ReportTargetType.Post, widget.post.id));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user