Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/src/widgets/content_item/content_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,15 @@ class _ContentItemState extends State<ContentItem> {
widget.isNSFW &&
context.read<AppController>().profile.coverMediaMarkedSensitive;

// If post body is long and has no whitespace just skip markdown rendering. It gets bogged down parsing it otherwise.
final renderAsMarkdown =
!widget.isPreview &&
!((widget.body?.length ?? 0) > 10000 &&
!RegExp(r'\s').hasMatch(widget.body ?? ''));

return widget.translation != null
// A translation is available
? widget.isPreview
? !renderAsMarkdown
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
Expand Down Expand Up @@ -703,7 +709,7 @@ class _ContentItemState extends State<ContentItem> {
],
)
// No translation is available
: widget.isPreview
: !renderAsMarkdown
? Text(widget.body!, maxLines: 4, overflow: TextOverflow.ellipsis)
: Markdown(widget.body!, widget.originInstance, nsfw: isNSFW);
}
Expand Down
Loading