Commit 6701105a cgx

用户点赞、发布评论接口添加user_id并且优化网络异常下点赞逻辑

1 个父辈 c54ebf24
......@@ -36,7 +36,7 @@
[self.detailView updateBottomView:self.comDynModel];
[self.detailView updateDetailView:requestModel.groupDatas];
} else {
[DSProgressHUD showToast:requestModel.errMessage];
}
}];
}
......@@ -45,7 +45,7 @@
- (void)fireCommentOrReply:(NSInteger)tag content:(NSString *)content {
if (tag == 1) { // 发布评论
[DSProgressHUD showProgressHUDWithInfo:@""];
[self.comDetailViewModel userCommentDynamicWithTalkID:self.comDynModel.dynamicID content:content completion:^(ComDetailViewModel * _Nonnull requestModel) {
[self.comDetailViewModel userCommentDynamicWithComDynModel:self.comDynModel content:content completion:^(ComDetailViewModel * _Nonnull requestModel) {
[DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) {
// 更新评论数
......@@ -57,7 +57,7 @@
[self.detailView updateCommentSection:requestModel.groupDatas];
} else {
[DSProgressHUD showToast:requestModel.errMessage];
}
}];
}
......@@ -72,7 +72,7 @@
- (void)fireTapDetailLikeBtn {
// 1、用户点赞或取消点赞直接响应UI变化
[ComListViewModel updateLikeData:self.comDynModel];
[self.detailView updateLikeStateAndLikeCount:self.comDynModel];
[self.detailView updateLikeStateAndLikeCount:self.comDynModel animate:YES];
// 2、更新点赞或取消点赞请求
if (self.likeDataTask) { [self.likeDataTask cancel]; }
......@@ -85,7 +85,7 @@
} else {
// 4、如果请求失败,延迟执行回退
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.detailView updateLikeStateAndLikeCount:self.comDynModel];
[self.detailView updateLikeStateAndLikeCount:self.comDynModel animate:NO];
[DSProgressHUD showToast:requestModel.errMessage];
});
}
......
......@@ -35,7 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 更新点赞状态和点赞数
/// @param model model
- (void)updateLikeStateAndLikeCount:(ComDynModel *)model;
/// @param animate 是否执行动画
- (void)updateLikeStateAndLikeCount:(ComDynModel *)model animate:(BOOL)animate;
/// 更新评论数
/// @param remarkCount remarkCount
......
......@@ -49,8 +49,8 @@
[self.interactView updateLikeBtnState:model.isLike likeCount:model.likeCount remarkCount:model.remarkCount];
}
- (void)updateLikeStateAndLikeCount:(ComDynModel *)model {
[self.interactView updateLikeBtnState:model.isLike likeCount:model.likeCount];
- (void)updateLikeStateAndLikeCount:(ComDynModel *)model animate:(BOOL)animate {
[self.interactView updateLikeBtnState:model.isLike likeCount:model.likeCount animate:animate];
}
- (void)updateRemarkCount:(int)remarkCount {
......@@ -102,7 +102,7 @@
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
ComDynModel *model = self.detailListArr[0];
return [model cellHeight:DynModelTypeDetail];
return [model cellHeight];
} else {
NSArray *comment_reply_arr = self.detailListArr[indexPath.section];
ComReplyModel *comReplyModel = comment_reply_arr[indexPath.row];
......@@ -151,7 +151,8 @@
if (!cell) {
cell = [[ComDynamicCell alloc] initWithCellType:DynModelTypeDetail style:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([ComDynamicCell class])];
}
cell.model = self.detailListArr[indexPath.section];
ComDynModel *model = self.detailListArr[indexPath.section];
cell.model = model;
return cell;
} else {
WS(weakSelf);
......
......@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak) id<InteractViewDelegate> delegate;
- (void)updateLikeBtnState:(BOOL)isLike likeCount:(int)likeCount remarkCount:(int)remarkCount;
- (void)updateLikeBtnState:(BOOL)isLike likeCount:(int)likeCount;
- (void)updateLikeBtnState:(BOOL)isLike likeCount:(int)likeCount animate:(BOOL)animate;
- (void)updateRemarkCount:(int)remarkCount;
/// 弹出回复输入框(第一版暂不考虑)
......
......@@ -63,8 +63,8 @@
[self.remarkCountBtn setTitle:[NSString stringWithFormat:@"%d", remarkCount] forState:UIControlStateNormal];
}
- (void)updateLikeBtnState:(BOOL)isLike likeCount:(int)likeCount {
[self.likeBtn executeAnimation];
- (void)updateLikeBtnState:(BOOL)isLike likeCount:(int)likeCount animate:(BOOL)animate {
if (animate) { [self.likeBtn executeAnimation]; }
[self.likeBtn updateLikeBtnState:isLike likeCount:likeCount];
}
......
......@@ -6,6 +6,7 @@
//
#import "DSNetworkTool.h"
@class ComDynModel;
NS_ASSUME_NONNULL_BEGIN
......@@ -24,10 +25,10 @@ NS_ASSUME_NONNULL_BEGIN
- (NSURLSessionDataTask *)queryDynamicCommentListWithTalkID:(int)talkID completion:(void (^)(ComDetailViewModel *requestModel))completion;
/// 用户-发布评论接口
/// @param talkID 动态id
/// @param model model
/// @param content 评论内容
/// @param completion completion
- (NSURLSessionDataTask *)userCommentDynamicWithTalkID:(int)talkID content:(NSString *)content completion:(void (^)(ComDetailViewModel *requestModel))completion;
- (NSURLSessionDataTask *)userCommentDynamicWithComDynModel:(ComDynModel *)model content:(NSString *)content completion:(void (^)(ComDetailViewModel *requestModel))completion;
/// 查询评论回复列表
/// @param commentID 动态评论id
......
......@@ -28,6 +28,7 @@
self.resCode = DSResCodeSuccess;
NSDictionary *resultDic = apiDic[@"result"];
ComDynModel *talkModel = [ComDynModel yy_modelWithDictionary:resultDic[@"talk"]];
talkModel.modelType = DynModelTypeDetail;
NSArray *comment_list = resultDic[@"comment_list"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < comment_list.count; i++) {
......@@ -44,9 +45,9 @@
}];
}
- (NSURLSessionDataTask *)userCommentDynamicWithTalkID:(int)talkID content:(NSString *)content completion:(void (^)(ComDetailViewModel *requestModel))completion {
- (NSURLSessionDataTask *)userCommentDynamicWithComDynModel:(ComDynModel *)model content:(NSString *)content completion:(void (^)(ComDetailViewModel *requestModel))completion {
NSString *api = @"user_comment_dynamic";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(talk_id:%d,content:\"%@\")}", api, talkID, content];
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(talk_id:%d,user_id:%d,content:\"%@\")}", api, model.dynamicID, model.userID, content];
return [ComDetailViewModel httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户-发布评论接口apiDic:%@", apiDic);
self.resCode = DSResCodeSuccess;
......
......@@ -107,7 +107,7 @@
+ (NSURLSessionDataTask *)userDynamicPraiseWithComDynModel:(ComDynModel *)comDynModel completion:(void (^)(ComListViewModel *requestModel))completion {
ComListViewModel * requestModel = [[ComListViewModel alloc] init];
NSString *api = @"user_dynamic_praise";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(talk_id:%d)}", api, comDynModel.dynamicID];
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(talk_id:%d,user_id:%d)}", api, comDynModel.dynamicID, comDynModel.userID];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户动态点赞、取消点赞接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!