处理发送评论

This commit is contained in:
2026-01-16 19:36:41 +08:00
parent ac0d9584d8
commit 663cb8493b

View File

@@ -475,12 +475,50 @@ static NSInteger const kRepliesLoadCount = 5;
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
_inputView.onSend = ^(NSString *text) { _inputView.onSend = ^(NSString *text) {
// TODO: [weakSelf sendCommentWithText:text];
NSLog(@"[KBAICommentView] Send comment: %@", text);
[weakSelf.inputView clearText];
}; };
} }
return _inputView; return _inputView;
} }
#pragma mark - Send Comment
- (void)sendCommentWithText:(NSString *)text {
if (text.length == 0) return;
//
KBAICommentModel *newComment = [[KBAICommentModel alloc] init];
newComment.commentId = [NSUUID UUID].UUIDString;
newComment.userId = @"current_user";
newComment.userName = @"我";
newComment.avatarUrl = @"";
newComment.content = text;
newComment.likeCount = 0;
newComment.isLiked = NO;
newComment.createTime = [[NSDate date] timeIntervalSince1970];
newComment.replies = @[];
//
CGFloat tableWidth = self.tableView.bounds.size.width;
if (tableWidth <= 0) {
tableWidth = [UIScreen mainScreen].bounds.size.width;
}
newComment.cachedHeaderHeight = [newComment calculateHeaderHeightWithMaxWidth:tableWidth];
//
[self.comments insertObject:newComment atIndex:0];
self.totalCommentCount++;
[self updateTitle];
// section
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:0]
withRowAnimation:UITableViewRowAnimationAutomatic];
//
[self.tableView setContentOffset:CGPointZero animated:YES];
//
[self.inputView clearText];
}
@end @end