@@ -59,9 +59,8 @@ @interface MRDetailViewController ()<UITableViewDataSource, UITableViewDelegate,
59
59
@property (strong , nonatomic ) NSString *activityPath;
60
60
@property (strong , nonatomic ) NSString *diffPath;
61
61
@property (strong , nonatomic ) ResourceReference *resourceReference;
62
- @property (strong , nonatomic ) NSArray *activityList;
62
+ @property (strong , nonatomic ) NSMutableArray *activityList;
63
63
@property (strong , nonatomic ) NSMutableArray *activityCList;
64
- @property (strong , nonatomic ) NSMutableArray *allDiscussions;
65
64
@property (nonatomic , strong ) NSMutableArray *projectUsers;
66
65
@property (strong , nonatomic ) NSString *reviewGoodPath;
67
66
@property (strong , nonatomic ) NSNumber *isLike;
@@ -85,8 +84,6 @@ - (void)viewDidLoad{
85
84
[super viewDidLoad ];
86
85
self.loadedActivty = false ;
87
86
self.activityList = [[NSMutableArray alloc ] init ];
88
- self.activityCList = [[NSMutableArray alloc ] init ];
89
- self.allDiscussions = [[NSMutableArray alloc ] init ];
90
87
self.title = [NSString stringWithFormat: @" %@ #%@ " , _curMRPR.des_project_name, _curMRPR.iid.stringValue];
91
88
self.referencePath = [NSString stringWithFormat: @" /api/user/%@ /project/%@ /resource_reference/%@ " , _curMRPR.des_owner_name, _curMRPR.des_project_name,self .curMRPR.iid];
92
89
self.activityPath = [NSString stringWithFormat: @" /api/user/%@ /project/%@ /git/merge/%@ /activities" , _curMRPR.des_owner_name, _curMRPR.des_project_name,self .curMRPR.iid];
@@ -187,32 +184,33 @@ - (void)configBottomView{
187
184
_myTableView.scrollIndicatorInsets = insets;
188
185
}
189
186
190
- -(void )sortActivityList {
191
- if (self.curMRPRInfo == nil ) {
192
- return ;
193
- }
194
- if (self.activityCList == nil ) {
195
- return ;
187
+ - (void )updateActivityList {
188
+ if (!_curMRPRInfo || !_activityCList) {
189
+ return ;
196
190
}
197
- NSMutableArray *dataArray = [[NSMutableArray alloc ] initWithArray: self .activityCList];
198
- for (int i = 0 ; i < self.allDiscussions .count ; i ++) {
199
- [dataArray addObject: self .allDiscussions[i]];
191
+ NSMutableArray *activityList = [NSMutableArray new ];
192
+ for (NSArray *list in _curMRPRInfo.discussions ) {
193
+ ProjectLineNote *note = list.firstObject ;
194
+ if (note.path .length > 0 ) {
195
+ note.action = @" mergeChanges" ;
196
+ }
197
+ [activityList addObject: note];
200
198
}
201
- self. activityList = [dataArray sortedArrayUsingComparator: ^ NSComparisonResult (ProjectLineNote *obj1, ProjectLineNote *obj2) {
202
- NSComparisonResult result = [ [ NSNumber numberWithDouble: [ obj1.created_at timeIntervalSinceReferenceDate ]] compare: [ NSNumber numberWithDouble: [ obj2.created_at timeIntervalSinceReferenceDate ]]];
203
- return result ;
199
+ [ activityList addObjectsFromArray: _activityCList];
200
+ [activityList sortUsingComparator: ^ NSComparisonResult (ProjectLineNote * obj1, ProjectLineNote * obj2) {
201
+ return [obj1.created_at compare: obj2.created_at] ;
204
202
}];
205
- [ self .myTableView reloadData ] ;
203
+ self.activityList = activityList ;
206
204
}
207
205
206
+
208
207
- (void )updateProjectStatus {
209
208
__weak typeof (self) weakSelf = self;
210
209
[[Coding_NetAPIManager sharedManager ] request_MRPRPreInfo_WithObj: _curMRPR andBlock: ^(MRPRBaseInfo *data, NSError *error) {
211
210
[weakSelf.view endLoading ];
212
211
[weakSelf.myRefreshControl endRefreshing ];
213
212
if (data) {
214
213
weakSelf.curPreMRPRInfo = (MRPRPreInfo*)data;
215
- [weakSelf sortActivityList ];
216
214
[weakSelf.myTableView reloadData ];
217
215
[weakSelf configBottomView ];
218
216
}
@@ -241,37 +239,40 @@ - (void)refresh{
241
239
[(MRPRBaseInfo *)data setContentHeight: weakSelf.curMRPRInfo.contentHeight];
242
240
}
243
241
weakSelf.curMRPRInfo = data;
244
- NSMutableArray *resultA = weakSelf.curMRPRInfo .discussions ;
245
- if (resultA != nil ){
246
- [weakSelf.allDiscussions removeAllObjects ];
247
- for (int i = 0 ; i<resultA.count ; i ++) {
248
- NSArray *pArray = resultA[i];
249
- ProjectLineNote* addTmp = pArray[0 ];
250
- if (addTmp.path != nil ) {
251
- addTmp.action = @" mergeChanges" ;
252
- }
253
- [weakSelf.allDiscussions addObject: addTmp];
254
- }
255
- }
256
- weakSelf.bottomView = nil ;
242
+ [weakSelf updateActivityList ];
257
243
[weakSelf configBottomView ];
258
- [weakSelf sortActivityList ];
244
+ [weakSelf.myTableView reloadData ];
259
245
}
246
+ [weakSelf.view configBlankPage: EaseBlankPageTypeMRForbidden hasData: data != nil hasError: (error != nil && error.code != 1400 ) reloadButtonBlock: ^(id sender) {
247
+ [weakSelf refresh ];
248
+ }];
260
249
}];
250
+ // MR 动态
251
+ [[CodingNetAPIClient sharedJsonClient ] requestJsonDataWithPath: self .activityPath withParams: @{@" iid" : _curMRPR.iid } withMethodType: Get andBlock: ^(id data, NSError *error) {
252
+ if (data) {
253
+ id resultData = [data valueForKeyPath: @" data" ];
254
+ weakSelf.activityCList = [NSObject arrayFromJSON: resultData ofObjects: @" ProjectLineNote" ];
255
+ [weakSelf updateActivityList ];
256
+ [weakSelf.myTableView reloadData ];
257
+ }
258
+ }];
259
+ // 项目成员
261
260
[[Coding_NetAPIManager sharedManager ] request_ProjectMembers_WithObj: self .curProject andBlock: ^(id data, NSError *error) {
262
261
[weakSelf.view endLoading ];
263
262
if (data) {
264
263
NSMutableArray * projectUsers = data;
265
264
weakSelf.projectUsers = projectUsers;
266
265
}
267
266
}];
267
+ // MR 评审者
268
268
[[Coding_NetAPIManager sharedManager ] request_MRReviewerInfo_WithObj: _curMRPR andBlock: ^(ReviewersInfo *data, NSError *error) {
269
269
[weakSelf.view endLoading ];
270
270
[weakSelf.myRefreshControl endRefreshing ];
271
271
if (data) {
272
272
weakSelf.curReviewersInfo = data;
273
273
}
274
274
}];
275
+ // 关联资源
275
276
[[CodingNetAPIClient sharedJsonClient ] requestJsonDataWithPath: self .referencePath withParams: @{@" iid" : _curMRPR.iid } withMethodType: Get andBlock: ^(id data, NSError *error) {
276
277
if (data) {
277
278
if (weakSelf.resourceReference == nil ) {
@@ -283,20 +284,7 @@ - (void)refresh{
283
284
284
285
}
285
286
}];
286
- [[CodingNetAPIClient sharedJsonClient ] requestJsonDataWithPath: self .activityPath withParams: @{@" iid" : _curMRPR.iid } withMethodType: Get andBlock: ^(id data, NSError *error) {
287
- if (data) {
288
- id resultData = [data valueForKeyPath: @" data" ];
289
- NSMutableArray *resultA = [NSObject arrayFromJSON: resultData ofObjects: @" ProjectLineNote" ];
290
- if (resultA != nil ){
291
- [weakSelf.activityCList removeAllObjects ];
292
- for (int i = 0 ; i<resultA.count ; i ++) {
293
- ProjectLineNote* addTmp = resultA[i];
294
- [weakSelf.activityCList addObject: addTmp];
295
- }
296
- [weakSelf sortActivityList ];
297
- }
298
- }
299
- }];
287
+ // 项目信息
300
288
if (!_curProject) {
301
289
_curProject = [Project new ];
302
290
_curProject.owner_user_name = _curMRPR.des_owner_name ;
@@ -420,7 +408,7 @@ - (void)authorizationMRPR{
420
408
[[Coding_NetAPIManager sharedManager ] request_MRPRAuthorization: _curMRPRInfo.mrpr andBlock: ^(id data, NSError *error) {
421
409
if (data) {
422
410
weakSelf.curPreMRPRInfo .mrpr .granted = @1 ;
423
- weakSelf.bottomView = nil ;
411
+ // weakSelf.bottomView = nil;
424
412
[weakSelf refresh ];
425
413
[weakSelf.myTableView reloadData ];
426
414
[weakSelf configBottomView ];
@@ -433,7 +421,7 @@ - (void)cancelAuthorizationMRPR{
433
421
[[Coding_NetAPIManager sharedManager ] request_MRPRCancelAuthorization: _curMRPRInfo.mrpr andBlock: ^(id data, NSError *error) {
434
422
if (data) {
435
423
weakSelf.curPreMRPRInfo .mrpr .granted = @0 ;
436
- weakSelf.bottomView = nil ;
424
+ // weakSelf.bottomView = nil;
437
425
[weakSelf refresh ];
438
426
[weakSelf.myTableView reloadData ];
439
427
[weakSelf configBottomView ];
@@ -457,7 +445,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger
457
445
458
446
#pragma mark TableM
459
447
- (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView {
460
- return self.activityList .count <= 0 ? 4 : 5 ;
448
+ return ! self.curMRPRInfo ? 0 : self. activityList .count > 0 ? 5 : 4 ;
461
449
}
462
450
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
463
451
NSInteger row = 0 ;
@@ -780,8 +768,7 @@ - (void)deleteComment:(ProjectLineNote *)lineNote{
780
768
__weak typeof (self) weakSelf = self;
781
769
[[Coding_NetAPIManager sharedManager ] request_DeleteLineNote: lineNote.id inProject: _curMRPRInfo.mrpr.des_project_name ofUser: _curMRPRInfo.mrpr.des_owner_name andBlock: ^(id data, NSError *error) {
782
770
if (data) {
783
- [weakSelf.allDiscussions removeObject: lineNote];
784
- [weakSelf sortActivityList ];
771
+ [weakSelf.activityList removeObject: lineNote];
785
772
[weakSelf.myTableView reloadData ];
786
773
}
787
774
}];
0 commit comments