Skip to content

Commit

Permalink
fix when comment.score is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
3003h committed Oct 30, 2023
1 parent 5369092 commit 4b2493b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
File renamed without changes.
5 changes: 3 additions & 2 deletions lib/pages/gallery/view/comment_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ class _CommentPageState extends State<CommentPage>

final comment = controller.comments?[index];
if (comment != null &&
(int.tryParse(comment.score) ?? 0) >
_ehSettingService.scoreFilteringThreshold) {
(comment.score.isEmpty ||
(int.tryParse(comment.score) ?? 0) >
_ehSettingService.scoreFilteringThreshold)) {
return CommentItem(
galleryComment: comment,
).autoCompressKeyboard(context);
Expand Down
10 changes: 9 additions & 1 deletion lib/pages/gallery/view/gallery_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,19 @@ class TopCommentEx extends StatelessWidget {
final List<GalleryComment>? comments;
final int max;

EhSettingService get _ehSettingService => Get.find();

@override
Widget build(BuildContext context) {
// 显示最前面两条
List<Widget> _topComment(List<GalleryComment>? comments, {int max = 2}) {
final Iterable<GalleryComment> _comments = comments?.take(max) ?? [];
final Iterable<GalleryComment> _comments = comments
?.where((comment) =>
comment.score.isEmpty ||
(int.tryParse(comment.score) ?? 0) >
_ehSettingService.scoreFilteringThreshold)
.take(max) ??
[];
return _comments
.map((GalleryComment comment) => CommentItem(
galleryComment: comment,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: fehviewer
description: An unofficial e-hentai app

publish_to: 'none'
version: 1.4.5+515
version: 1.4.6+516

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down

0 comments on commit 4b2493b

Please sign in to comment.