opt: reply del
This commit is contained in:
@ -125,6 +125,7 @@ class ReplyControl {
|
||||
this.upLike,
|
||||
this.isShow,
|
||||
this.entryText,
|
||||
this.entryTextNum,
|
||||
this.titleText,
|
||||
this.time,
|
||||
this.location,
|
||||
@ -135,6 +136,7 @@ class ReplyControl {
|
||||
bool? upLike;
|
||||
bool? isShow;
|
||||
String? entryText;
|
||||
int? entryTextNum;
|
||||
String? titleText;
|
||||
String? time;
|
||||
String? location;
|
||||
@ -155,6 +157,10 @@ class ReplyControl {
|
||||
}
|
||||
|
||||
entryText = json['sub_reply_entry_text'];
|
||||
// 正则匹配
|
||||
entryTextNum = json['sub_reply_entry_text'] != null
|
||||
? int.parse(RegExp(r"\d+").stringMatch(json['sub_reply_entry_text']!)!)
|
||||
: 0;
|
||||
titleText = json['sub_reply_title_text'];
|
||||
time = json['time_desc'];
|
||||
location = json['location'] != null ? json['location'].split(':')[1] : '';
|
||||
|
@ -123,4 +123,15 @@ class DynamicDetailController extends GetxController {
|
||||
Future onLoad() async {
|
||||
queryReplyList(reqType: 'onLoad');
|
||||
}
|
||||
|
||||
Future removeReply(int? rpid, int? frpid) async {
|
||||
// 移除一楼评论
|
||||
if (rpid != null) {
|
||||
replyList.removeWhere((item) {
|
||||
return item.rpid == rpid;
|
||||
});
|
||||
}
|
||||
|
||||
/// TODO 移除二楼评论
|
||||
}
|
||||
}
|
||||
|
@ -335,6 +335,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
.replies!
|
||||
.add(replyItem);
|
||||
},
|
||||
onDelete:
|
||||
_dynamicDetailController.removeReply,
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -145,7 +145,15 @@ class VideoReplyController extends GetxController {
|
||||
if (frpid != 0 && frpid != null) {
|
||||
replyList.value = replyList.map((item) {
|
||||
if (item.rpid! == frpid) {
|
||||
return item..replies!.removeWhere((reply) => reply.rpid == rpid);
|
||||
item.replies!.removeWhere((reply) => reply.rpid == rpid);
|
||||
// 【共xx条回复】
|
||||
if (item.replyControl != null &&
|
||||
item.replyControl!.entryTextNum! >= 1) {
|
||||
item.replyControl!.entryTextNum =
|
||||
item.replyControl!.entryTextNum! - 1;
|
||||
item.rcount = item.replyControl!.entryTextNum;
|
||||
}
|
||||
return item;
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ class ReplyItemRow extends StatelessWidget {
|
||||
if (replyControl!.upReply!)
|
||||
const TextSpan(text: 'up主等人 '),
|
||||
TextSpan(
|
||||
text: replyControl!.entryText!,
|
||||
text: '查看${replyControl!.entryTextNum}条回复',
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
@ -1089,16 +1089,12 @@ class MorePanel extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
print('item.rpid: ${item.rpid}');
|
||||
onDelete?.call(item.rpid!, item.root);
|
||||
return;
|
||||
var result = await ReplyHttp.replyDel(
|
||||
type: item.type!,
|
||||
oid: item.oid!,
|
||||
rpid: item.rpid!,
|
||||
);
|
||||
if (result['status']) {
|
||||
// SmartDialog.showToast('评论删除成功,需手动刷新');
|
||||
onDelete?.call(item.rpid!, item.root);
|
||||
Get.back();
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user