Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Let admin/owner delete anon comments

Neeraj Gupta5c4525442f28
diff --git a/mobile/apps/photos/lib/ui/social/comments_screen.dart b/mobile/apps/photos/lib/ui/social/comments_screen.dart
index 87653bc867..ff9baddeaa 100644
--- a/mobile/apps/photos/lib/ui/social/comments_screen.dart
+++ b/mobile/apps/photos/lib/ui/social/comments_screen.dart
@@ -371,10 +371,26 @@ class _FileCommentsScreenState extends State<FileCommentsScreen> {
});
}
+ Collection? get _currentCollection {
+ if (_sharedCollections.isEmpty) {
+ return null;
+ }
+ return _sharedCollections
+ .firstWhere(
+ (c) => c.collection.id == _selectedCollectionID,
+ orElse: () => _sharedCollections.first,
+ )
+ .collection;
+ }
+
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
+ final selectedCollection = _currentCollection;
+ final canModerateAnonComments = selectedCollection != null &&
+ (selectedCollection.isOwner(_currentUserID) ||
+ selectedCollection.isAdmin(_currentUserID));
return Scaffold(
appBar: AppBar(
@@ -437,6 +453,7 @@ class _FileCommentsScreenState extends State<FileCommentsScreen> {
comment: comment,
user: _getUserForComment(comment),
isOwnComment: comment.userID == _currentUserID,
+ canModerateAnonComments: canModerateAnonComments,
currentUserID: _currentUserID,
collectionID: _selectedCollectionID,
isHighlighted: comment.id == _highlightedCommentID,
diff --git a/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart
index ea2502888a..8a68186987 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart
@@ -25,6 +25,7 @@ class CommentBubbleWidget extends StatefulWidget {
final Comment comment;
final User user;
final bool isOwnComment;
+ final bool canModerateAnonComments;
final int currentUserID;
final int collectionID;
final Future<Comment?> Function()? onFetchParent;
@@ -40,6 +41,7 @@ class CommentBubbleWidget extends StatefulWidget {
required this.comment,
required this.user,
required this.isOwnComment,
+ required this.canModerateAnonComments,
required this.currentUserID,
required this.collectionID,
this.onFetchParent,
@@ -284,6 +286,9 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget>
double bubbleScale = 1.0,
double capsuleOpacity = 1.0,
}) {
+ final canDeleteComment = widget.isOwnComment ||
+ (widget.canModerateAnonComments && widget.comment.isAnonymous);
+
return Padding(
padding: EdgeInsets.only(
right: widget.isOwnComment ? 6 : 0,
@@ -365,8 +370,8 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget>
_hideHighlight();
widget.onReplyTap();
},
- onDeleteTap: _handleDelete,
- showDelete: widget.isOwnComment,
+ onDeleteTap: canDeleteComment ? _handleDelete : null,
+ showDelete: canDeleteComment,
),
),
],