opt: use cascade (#812)

This commit is contained in:
My-Responsitories
2025-05-04 23:08:06 +08:00
committed by GitHub
parent 877732e1e7
commit 6f69a45195
25 changed files with 52 additions and 88 deletions

View File

@@ -360,12 +360,8 @@ class _VideoReplyReplyPanelState
if (res != null) {
_savedReplies[key] = null;
ReplyInfo replyInfo = RequestUtils.replyCast(res);
List<ReplyInfo> list =
_videoReplyReplyController.loadingState.value is Success
? (_videoReplyReplyController.loadingState.value as Success)
.response
: <ReplyInfo>[];
list.insert(index + 1, replyInfo);
_videoReplyReplyController.loadingState.value.dataOrNull
?.insert(index + 1, replyInfo);
_videoReplyReplyController.count.value += 1;
_videoReplyReplyController.loadingState.refresh();
if (_videoReplyReplyController.enableCommAntifraud && mounted) {
@@ -462,9 +458,7 @@ class _VideoReplyReplyPanelState
_onReply(replyItem, index);
},
onDelete: (subIndex) {
List<ReplyInfo> list =
(_videoReplyReplyController.loadingState.value as Success).response;
list.removeAt(index);
_videoReplyReplyController.loadingState.value.data!.removeAt(index);
_videoReplyReplyController.count.value -= 1;
_videoReplyReplyController.loadingState.refresh();
},