Browse Source

朋友圈评论删除

桂欢 1 year ago
parent
commit
411a5b0e00

+ 2 - 0
SLAiELTS/SLAiELTS/Tool/MLEmojiLabel/MLLabel/Classes/MLLinkLabel.h

@@ -81,6 +81,8 @@ typedef NS_ENUM(NSUInteger, MLLinkType) {
 
 
 @property (nonatomic, copy) void (^labelClickedBlock)(void);
 @property (nonatomic, copy) void (^labelClickedBlock)(void);
 
 
+@property (nonatomic, copy) void (^labelLongTouchBlock)(void);
+
 
 
 /**
 /**
  *  link在正式add之前可以自定义修改属性的block
  *  link在正式add之前可以自定义修改属性的block

+ 6 - 2
SLAiELTS/SLAiELTS/Tool/MLEmojiLabel/MLLabel/Classes/MLLinkLabel.m

@@ -438,8 +438,7 @@ static NSArray * kAllRegexps() {
             return YES;
             return YES;
         }
         }
     }
     }
-    
-    return NO;
+    return YES;
 }
 }
 
 
 - (void)longPressGestureDidFire:(UILongPressGestureRecognizer *)sender {
 - (void)longPressGestureDidFire:(UILongPressGestureRecognizer *)sender {
@@ -458,6 +457,11 @@ static NSArray * kAllRegexps() {
             }
             }
         }
         }
     }
     }
+    if (sender.state == UIGestureRecognizerStateEnded) {
+        if (self.labelLongTouchBlock) {
+            self.labelLongTouchBlock();
+        }
+    }
 }
 }
 
 
 
 

+ 1 - 1
SLAiELTS/SLAiELTS/ViewControllers/Moments/Model/SDTimeLineCellModel.h

@@ -50,7 +50,7 @@ typedef enum {
 @property (nonatomic, assign) CGSize imageSize;
 @property (nonatomic, assign) CGSize imageSize;
 
 
 @property (nonatomic, strong) NSMutableArray<SDTimeLineCellLikeItemModel *> *likeItemsArray;
 @property (nonatomic, strong) NSMutableArray<SDTimeLineCellLikeItemModel *> *likeItemsArray;
-@property (nonatomic, strong) NSArray<SDTimeLineCellCommentItemModel *> *list;
+@property (nonatomic, strong) NSMutableArray<SDTimeLineCellCommentItemModel *> *list;
 
 
 @property (nonatomic, strong) NSArray *likeStr;
 @property (nonatomic, strong) NSArray *likeStr;
 
 

+ 20 - 2
SLAiELTS/SLAiELTS/ViewControllers/Moments/MomentsVc/SLMomentsVc.m

@@ -226,6 +226,7 @@ static CGFloat textFieldH = 56;
         commentItemModel.content = text;
         commentItemModel.content = text;
         commentItemModel.friendId = model.friendId;
         commentItemModel.friendId = model.friendId;
         commentItemModel.level = [parameter objectForKey:@"level"];
         commentItemModel.level = [parameter objectForKey:@"level"];
+        commentItemModel.commendId = [responseObject objectForKey:@"data"];
         [temp addObject:commentItemModel];
         [temp addObject:commentItemModel];
         model.list = [temp copy];
         model.list = [temp copy];
         [self.tableView reloadRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone];
         [self.tableView reloadRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone];
@@ -362,14 +363,31 @@ static CGFloat textFieldH = 56;
         
         
         [cell setDidClickCommentLabelBlock:^(NSString *commentId, CGRect rectInWindow,  NSIndexPath *indexPath1) {
         [cell setDidClickCommentLabelBlock:^(NSString *commentId, CGRect rectInWindow,  NSIndexPath *indexPath1) {
             weakSelf.currentEditingIndexthPath = [NSIndexPath indexPathForRow:indexPath1.row inSection:0];
             weakSelf.currentEditingIndexthPath = [NSIndexPath indexPathForRow:indexPath1.row inSection:0];
-            SDTimeLineCellModel *model1 = weakSelf.dataArray[indexPath1.row];
+            SDTimeLineCellModel *editModel = weakSelf.dataArray[indexPath1.row];
             [weakSelf.textField becomeFirstResponder];
             [weakSelf.textField becomeFirstResponder];
             weakSelf.isReplayingComment = YES;
             weakSelf.isReplayingComment = YES;
-            weakSelf.currentCommentItemModel = [model1.list objectAtIndex:indexPath1.section];
+            weakSelf.currentCommentItemModel = [editModel.list objectAtIndex:indexPath1.section];
             weakSelf.commentToUser = commentId;
             weakSelf.commentToUser = commentId;
             [weakSelf adjustTableViewToFitKeyboard];
             [weakSelf adjustTableViewToFitKeyboard];
         }];
         }];
         
         
+        [cell setDidLongTouchCommentLabelBlock:^(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath1) {
+            //indexPath1 row == table row  Section == SDTimeLineCellCommentItemModel.list
+            SDTimeLineCellModel *editModel = [weakSelf.dataArray objectAtIndex:indexPath1.row];
+            if ([editModel.userId isEqualToString:[SLGlobalInfo SharedInstance].loginInfo.user.userId]) {
+                NSMutableArray *temp = [NSMutableArray new];
+                [temp addObjectsFromArray:editModel.list];
+                SDTimeLineCellCommentItemModel *commentModel = [editModel.list objectAtIndex:indexPath1.section];
+                [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Friend/DelateComment" parameter:@{@"commentId":commentModel.commendId} success:^(id responseObject) {
+                    [temp removeObjectAtIndex:indexPath1.section];
+                    editModel.list = [temp copy];
+                    [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath1] withRowAnimation:UITableViewRowAnimationNone];
+                } failure:^(SPRequestError *error) {
+
+                }];
+            }
+        }];
+        
         cell.delegate = self;
         cell.delegate = self;
     }
     }
     
     

+ 3 - 0
SLAiELTS/SLAiELTS/ViewControllers/Moments/Views/Cell/SDTimeLineCell.h

@@ -50,4 +50,7 @@
 
 
 @property (nonatomic, copy) void (^didClickCommentLabelBlock)(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath);
 @property (nonatomic, copy) void (^didClickCommentLabelBlock)(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath);
 
 
+@property (nonatomic, copy) void (^didLongTouchCommentLabelBlock)(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath);
+
+
 @end
 @end

+ 5 - 0
SLAiELTS/SLAiELTS/ViewControllers/Moments/Views/Cell/SDTimeLineCell.m

@@ -247,6 +247,11 @@ NSString *const kSDTimeLineCellOperationButtonClickedNotification = @"SDTimeLine
     _commentView.didClickCommentLabelBlock = _didClickCommentLabelBlock;
     _commentView.didClickCommentLabelBlock = _didClickCommentLabelBlock;
 }
 }
 
 
+- (void)setDidLongTouchCommentLabelBlock:(void (^)(NSString *, CGRect, NSIndexPath *))didLongTouchCommentLabelBlock {
+    _didLongTouchCommentLabelBlock = didLongTouchCommentLabelBlock;
+    _commentView.didLongTouchCommentLabelBlock = _didLongTouchCommentLabelBlock;
+}
+
 - (void)dealloc
 - (void)dealloc
 {
 {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [[NSNotificationCenter defaultCenter] removeObserver:self];

+ 2 - 0
SLAiELTS/SLAiELTS/ViewControllers/Moments/Views/CommentView/SDTimeLineCellCommentView.h

@@ -38,4 +38,6 @@
 
 
 @property (nonatomic, copy) void (^didClickCommentLabelBlock)(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath);
 @property (nonatomic, copy) void (^didClickCommentLabelBlock)(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath);
 
 
+@property (nonatomic, copy) void (^didLongTouchCommentLabelBlock)(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath);
+
 @end
 @end

+ 6 - 0
SLAiELTS/SLAiELTS/ViewControllers/Moments/Views/CommentView/SDTimeLineCellCommentView.m

@@ -118,6 +118,12 @@
         label.textColor = SLColor(@"#48484A");
         label.textColor = SLColor(@"#48484A");
         label.delegate = self;
         label.delegate = self;
         WS(weakSelf);
         WS(weakSelf);
+        label.labelLongTouchBlock = ^{
+            NSLog(@"didLongTouchCommentLabelBlock--%d---------commentItemsArray",i);
+            if (weakSelf.didLongTouchCommentLabelBlock) {
+                weakSelf.didLongTouchCommentLabelBlock(@"123", CGRectZero, [NSIndexPath indexPathForRow:self.indexPath.row inSection:i]);
+            }
+        };
         label.labelClickedBlock = ^{
         label.labelClickedBlock = ^{
             NSLog(@"%d---------commentItemsArray",i);
             NSLog(@"%d---------commentItemsArray",i);
             if (weakSelf.didClickCommentLabelBlock) {
             if (weakSelf.didClickCommentLabelBlock) {