2222
2323@interface FileActivitiesViewController ()<UITableViewDataSource, UITableViewDelegate, TTTAttributedLabelDelegate, EaseToolBarDelegate>
2424@property (strong , nonatomic ) ProjectFile *curFile;
25- @property (strong , nonatomic ) Project *curProject;
2625@property (strong , nonatomic ) NSMutableArray *activityList;
2726
2827@property (strong , nonatomic ) UITableView *myTableView;
@@ -39,17 +38,6 @@ + (instancetype)vcWithFile:(ProjectFile *)file{
3938 return vc;
4039}
4140
42- - (void )setCurFile : (ProjectFile *)curFile {
43- _curFile = curFile;
44- if (!_curProject) {
45- NSString *project_id_str = [[[[_curFile.owner_preview componentsSeparatedByString: @" project/" ] lastObject ] componentsSeparatedByString: @" /" ] firstObject ];
46- if (project_id_str.length > 0 && [project_id_str isPureInt ]) {
47- _curProject = [Project new ];
48- _curProject.id = [NSNumber numberWithInteger: project_id_str.integerValue];
49- }
50- }
51- }
52-
5341- (void )viewDidLoad
5442{
5543 [super viewDidLoad ];
@@ -194,52 +182,59 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
194182 }else if ([title isEqualToString: @" 删除" ]){
195183 [weakSelf deleteCommentOfActivity: curActivity];
196184 }else if ([title isEqualToString: @" 回复" ]){
197- [weakSelf goToAddCommentVCToUser : curActivity.projectFileComment.owner.name ];
185+ [weakSelf goToAddCommentVCToActivity : curActivity];
198186 }
199187 }];
200188}
201189
202190
203191#pragma mark Comment
204- - (void )goToAddCommentVCToUser : (NSString *)userName {
205- DebugLog (@" %@ " , userName);
192+ - (void )goToAddCommentVCToActivity : (ProjectActivity *)curActivity {
193+ Project *curProject;
194+ if (curActivity.project ) {
195+ curProject = curActivity.project ;
196+ }
197+ if (!curProject && _activityList.count > 0 ) {
198+ curProject = [(ProjectActivity *)[_activityList firstObject ] project ];
199+ }
200+ if (!curProject) {
201+ curProject = [Project new ];
202+ }
203+ curProject.id = _curFile.project_id ;
204+
206205 AddMDCommentViewController *vc = [AddMDCommentViewController new ];
206+
207+ vc.curProject = curProject;
207208
208- // vc.curProject = _curProject;
209- // vc.requestPath = [NSString stringWithFormat:@"api/user/%@/project/%@/git/line_notes", _curMRPR.des_owner_name, _curMRPR.des_project_name];
210- // vc.requestParams = [@{
211- // @"noteable_type" : [self.curMRPRInfo.mrpr isMR]? @"MergeRequestBean" : @"PullRequestBean",
212- // @"noteable_id" : _curMRPRInfo.mrpr.id,
213- // } mutableCopy];
214- // vc.contentStr = userName.length > 0? [NSString stringWithFormat:@"@%@ ", userName]: nil;
215- // @weakify(self);
216- // vc.completeBlock = ^(id data){
217- // @strongify(self);
218- // if (data && [data isKindOfClass:[ProjectLineNote class]]) {
219- // [self.curMRPRInfo.discussions addObject:@[data]];
220- // [self.myTableView reloadData];
221- // }
222- // };
209+ vc.requestPath = [NSString stringWithFormat: @" api/project/%@ /files/%@ /comment" , _curFile.project_id.stringValue, _curFile.file_id.stringValue];
210+ vc.requestParams = [@{} mutableCopy];
211+ vc.contentStr = curActivity? [NSString stringWithFormat: @" @%@ " , curActivity.user.name]: nil ;
223212
213+ @weakify (self);
214+ vc.completeBlock = ^(id data){
215+ @strongify (self);
216+ if (data) {
217+ [self refresh ];
218+ }
219+ };
224220 [self .navigationController pushViewController: vc animated: YES ];
225221}
226222
227223
228- - (void )deleteCommentOfActivity : (ProjectActivity *)lineNote {
229- // __weak typeof(self) weakSelf = self;
230- // [[Coding_NetAPIManager sharedManager] request_DeleteLineNote:lineNote. id inProject:_curMRPRInfo.mrpr.des_project_name ofUser:_curMRPRInfo.mrpr.des_owner_name andBlock:^(id data, NSError *error) {
231- // if (data) {
232- // [weakSelf.curMRPRInfo.discussions removeObject:@[lineNote] ];
233- // [weakSelf.myTableView reloadData];
234- // }
235- // }];
224+ - (void )deleteCommentOfActivity : (ProjectActivity *)curActivity {
225+ __weak typeof (self) weakSelf = self;
226+ [[Coding_NetAPIManager sharedManager ] request_DeleteComment: curActivity.projectFileComment. id inFile: _curFile andBlock: ^(id data, NSError *error) {
227+ if (data) {
228+ [weakSelf.activityList removeObject: curActivity ];
229+ [weakSelf.myTableView reloadData ];
230+ }
231+ }];
236232}
237233
238-
239234#pragma mark EaseToolBarDelegate
240235- (void )easeToolBar : (EaseToolBar *)toolBar didClickedIndex : (NSInteger )index {
241236 // 去添加评论
242-
237+ [ self goToAddCommentVCToActivity: nil ];
243238}
244239
245240@end
0 commit comments