mod: reply2reply: query root

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-10 17:22:59 +08:00
parent ca1d084fc6
commit 3d67c5939c
3 changed files with 36 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
import 'package:PiliPalaX/grpc/grpc_repo.dart';
import 'package:PiliPalaX/http/loading_state.dart';
import 'package:PiliPalaX/pages/common/common_controller.dart';
import 'package:flutter/material.dart';
@@ -42,6 +43,8 @@ class VideoReplyReplyController extends CommonController
AnimationController? controller;
Animation<Color?>? colorAnimation;
ReplyInfo? firstFloor;
@override
void onInit() {
super.onInit();
@@ -77,8 +80,21 @@ class VideoReplyReplyController extends CommonController
// }
@override
Future queryData([bool isRefresh = true]) {
Future queryData([bool isRefresh = true]) async {
if (['没有更多了', '还没有评论'].contains(noMore.value)) return Future.value();
if (!isDialogue &&
currentPage == 1 &&
!hasRoot &&
firstFloor == null &&
rpid != null) {
await GrpcRepo.replyInfo(
rpid: rpid!,
).then((res) {
if (res['status'] && (res['data']?.mid ?? -1) > 0) {
firstFloor = res['data'];
}
});
}
return super.queryData(isRefresh);
}

View File

@@ -47,6 +47,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
late final itemPositionsListener = ItemPositionsListener.create();
late final _key = GlobalKey<ScaffoldState>();
ReplyInfo? get firstFloor =>
widget.firstFloor ?? _videoReplyReplyController.firstFloor;
@override
void initState() {
super.initState();
@@ -75,7 +78,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
super.dispose();
}
Widget get _header => widget.firstFloor == null
Widget get _header => firstFloor == null
? _sortWidget
: ValueListenableBuilder<Iterable<ItemPosition>>(
valueListenable: itemPositionsListener.itemPositions,
@@ -147,16 +150,16 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
return Obx(() => _buildBody(
_videoReplyReplyController.loadingState.value,
index));
} else if (widget.firstFloor != null) {
} else if (firstFloor != null) {
if (index == 0) {
return ReplyItemGrpc(
replyItem: widget.firstFloor!,
replyItem: firstFloor!,
replyLevel: '2',
showReplyRow: false,
replyType: widget.replyType,
needDivider: false,
onReply: () {
_onReply(widget.firstFloor!);
_onReply(firstFloor!);
},
upMid: _videoReplyReplyController.upMid,
);
@@ -390,7 +393,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
return (loadingState is Success ? loadingState.response.length : 0) + 1;
}
int itemCount = 0;
if (widget.firstFloor != null) {
if (firstFloor != null) {
itemCount = 2;
}
if (loadingState is Success) {