feat: add comment keyword blocking functionality

This commit is contained in:
2025-11-29 14:52:24 +08:00
parent 053293839e
commit 38b5947c0a
5 changed files with 114 additions and 3 deletions

View File

@@ -1,5 +1,18 @@
part of 'comic_page.dart';
bool _shouldBlockComment(Comment comment) {
var blockedWords = appdata.settings["blockedCommentWords"] as List;
if (blockedWords.isEmpty) return false;
var content = comment.content.toLowerCase();
for (var word in blockedWords) {
if (content.contains(word.toString().toLowerCase())) {
return true;
}
}
return false;
}
class CommentsPage extends StatefulWidget {
const CommentsPage({
super.key,
@@ -36,8 +49,9 @@ class _CommentsPageState extends State<CommentsPage> {
_loading = false;
});
} else if (mounted) {
var filteredComments = res.data.where((c) => !_shouldBlockComment(c)).toList();
setState(() {
_comments = res.data;
_comments = filteredComments;
_loading = false;
maxPage = res.subData;
});
@@ -54,8 +68,9 @@ class _CommentsPageState extends State<CommentsPage> {
if (res.error) {
context.showMessage(message: res.errorMessage ?? "Unknown Error");
} else {
var filteredComments = res.data.where((c) => !_shouldBlockComment(c)).toList();
setState(() {
_comments!.addAll(res.data);
_comments!.addAll(filteredComments);
_page++;
if (maxPage == null && res.data.isEmpty) {
maxPage = _page;