From 717bccbf3fde6179205f49516b180d13d94255ef Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 12 Dec 2024 00:48:03 +0800 Subject: [PATCH] :sparkles: Preload post quoted content --- lib/providers/post.dart | 5 +++++ lib/widgets/post/post_item.dart | 35 +++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/lib/providers/post.dart b/lib/providers/post.dart index 46d30ae..ba98350 100644 --- a/lib/providers/post.dart +++ b/lib/providers/post.dart @@ -23,6 +23,11 @@ class SnPostContentProvider { if (out[i].body['thumbnail'] != null) { rids.add(out[i].body['thumbnail']); } + if (out[i].repostTo != null) { + out[i] = out[i].copyWith( + repostTo: await _preloadRelatedDataSingle(out[i].repostTo!), + ); + } } final attachments = await _attach.getMultiple(rids.toList()); diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 9405893..889d70d 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -637,16 +637,35 @@ class _PostQuoteContent extends StatelessWidget { width: 1, ), ), - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + padding: const EdgeInsets.only(top: 8), child: Column( children: [ - _PostContentHeader( - data: child, - isCompact: true, - showMenu: false, - onDeleted: () {}, - ).padding(bottom: 4), - _PostContentBody(data: child), + Column( + children: [ + _PostContentHeader( + data: child, + isCompact: true, + showMenu: false, + onDeleted: () {}, + ).padding(bottom: 4), + _PostContentBody(data: child), + if (child.visibility > 0) _PostVisibilityHint(data: child).padding(top: 4), + ], + ).padding(horizontal: 16), + if (child.preload?.attachments?.isNotEmpty ?? false) + ClipRRect( + borderRadius: const BorderRadius.only( + bottomLeft: Radius.circular(8), + bottomRight: Radius.circular(8), + ), + child: AttachmentList( + data: child.preload!.attachments!, + listPadding: const EdgeInsets.symmetric(horizontal: 12), + ), + ).padding( + top: 8, + bottom: (child.preload?.attachments?.length ?? 0) > 1 ? 12 : 0, + ), ], ), ),