revert: 评论详情优先展示二级评论

This commit is contained in:
guozhigq
2024-04-28 07:39:55 +08:00
parent 72ee515ae5
commit 1b8b3947be
6 changed files with 11 additions and 32 deletions

View File

@ -106,7 +106,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
} }
// 查看二级评论 // 查看二级评论
void replyReply(replyItem, currentReply) { void replyReply(replyItem) {
int oid = replyItem.oid; int oid = replyItem.oid;
int rpid = replyItem.rpid!; int rpid = replyItem.rpid!;
Get.to( Get.to(
@ -324,8 +324,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
replyItem: replyList[index], replyItem: replyList[index],
showReplyRow: true, showReplyRow: true,
replyLevel: '1', replyLevel: '1',
replyReply: (replyItem, currentReply) => replyReply: (replyItem) =>
replyReply(replyItem, currentReply), replyReply(replyItem),
replyType: ReplyType.values[replyType], replyType: ReplyType.values[replyType],
addReply: (replyItem) { addReply: (replyItem) {
replyList[index] replyList[index]

View File

@ -174,7 +174,6 @@ class VideoDetailController extends GetxController
replyType: ReplyType.video, replyType: ReplyType.video,
source: 'videoDetail', source: 'videoDetail',
sheetHeight: sheetHeight.value, sheetHeight: sheetHeight.value,
currentReply: currentReply,
); );
}); });
replyReplyBottomSheetCtr?.closed.then((value) { replyReplyBottomSheetCtr?.closed.then((value) {

View File

@ -112,7 +112,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
} }
// 展示二级回复 // 展示二级回复
void replyReply(replyItem, currentReply) { void replyReply(replyItem) {
final VideoDetailController videoDetailCtr = final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag); Get.find<VideoDetailController>(tag: heroTag);
if (replyItem != null) { if (replyItem != null) {
@ -232,8 +232,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
.replyList[index], .replyList[index],
showReplyRow: true, showReplyRow: true,
replyLevel: replyLevel, replyLevel: replyLevel,
replyReply: (replyItem, currentReply) => replyReply: (replyItem) =>
replyReply(replyItem, currentReply), replyReply(replyItem),
replyType: ReplyType.video, replyType: ReplyType.video,
); );
} }

View File

@ -533,10 +533,8 @@ InlineSpan buildContent(
TextSpan( TextSpan(
text: str, text: str,
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () => replyReply?.call( ..onTap = () =>
replyItem.root == 0 ? replyItem : fReplyItem, replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem),
replyItem,
),
), ),
); );
} }

View File

@ -26,7 +26,7 @@ class VideoReplyReplyController extends GetxController {
currentPage = 0; currentPage = 0;
} }
Future queryReplyList({type = 'init', currentReply}) async { Future queryReplyList({type = 'init'}) async {
if (type == 'init') { if (type == 'init') {
currentPage = 0; currentPage = 0;
} }
@ -63,14 +63,6 @@ class VideoReplyReplyController extends GetxController {
// res['data'].replies.addAll(replyList); // res['data'].replies.addAll(replyList);
} }
} }
if (replyList.isNotEmpty && currentReply != null) {
int indexToRemove =
replyList.indexWhere((item) => currentReply.rpid == item.rpid);
// 如果找到了指定ID的项则移除
if (indexToRemove != -1) {
replyList.removeAt(indexToRemove);
}
}
isLoadingMore = false; isLoadingMore = false;
return res; return res;
} }

View File

@ -20,7 +20,6 @@ class VideoReplyReplyPanel extends StatefulWidget {
this.source, this.source,
this.replyType, this.replyType,
this.sheetHeight, this.sheetHeight,
this.currentReply,
super.key, super.key,
}); });
final int? oid; final int? oid;
@ -30,7 +29,6 @@ class VideoReplyReplyPanel extends StatefulWidget {
final String? source; final String? source;
final ReplyType? replyType; final ReplyType? replyType;
final double? sheetHeight; final double? sheetHeight;
final dynamic currentReply;
@override @override
State<VideoReplyReplyPanel> createState() => _VideoReplyReplyPanelState(); State<VideoReplyReplyPanel> createState() => _VideoReplyReplyPanelState();
@ -65,9 +63,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
}, },
); );
_futureBuilderFuture = _videoReplyReplyController.queryReplyList( _futureBuilderFuture = _videoReplyReplyController.queryReplyList();
currentReply: widget.currentReply,
);
} }
void replyReply(replyItem) {} void replyReply(replyItem) {}
@ -111,9 +107,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
onRefresh: () async { onRefresh: () async {
setState(() {}); setState(() {});
_videoReplyReplyController.currentPage = 0; _videoReplyReplyController.currentPage = 0;
return await _videoReplyReplyController.queryReplyList( return await _videoReplyReplyController.queryReplyList();
currentReply: widget.currentReply,
);
}, },
child: CustomScrollView( child: CustomScrollView(
controller: _videoReplyReplyController.scrollController, controller: _videoReplyReplyController.scrollController,
@ -146,10 +140,6 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
Map? data = snapshot.data; Map? data = snapshot.data;
if (data != null && data['status']) { if (data != null && data['status']) {
if (widget.currentReply != null) {
_videoReplyReplyController.replyList
.insert(0, widget.currentReply);
}
// 请求成功 // 请求成功
return Obx( return Obx(
() => SliverList( () => SliverList(