Skip to content

Commit 1780eb9

Browse files
committed
创建项目之后,项目没有置顶的bug
1 parent 4596fe2 commit 1780eb9

2 files changed

Lines changed: 26 additions & 19 deletions

File tree

Coding_iOS/Controllers/NewProject/NewProjectViewController.m

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,20 @@ -(void)submit{
128128
__weak typeof(self) weakSelf = self;
129129
[[Coding_NetAPIManager sharedManager] request_NewProject_WithObj:project image:self.projectIconImage andBlock:^(NSString *data, NSError *error) {
130130
if (data.length > 0) {
131-
[weakSelf gotoProWithStr:data];
131+
132+
NSString *projectRegexStr = @"/u/([^/]+)/p/([^/]+)";
133+
NSArray *matchedCaptures = [data captureComponentsMatchedByRegex:projectRegexStr];
134+
if (matchedCaptures.count >= 3) {
135+
NSString *user_global_key = matchedCaptures[1];
136+
NSString *project_name = matchedCaptures[2];
137+
Project *curPro = [[Project alloc] init];
138+
curPro.owner_user_name = user_global_key;
139+
curPro.name = project_name;
140+
//标记已读
141+
[[Coding_NetAPIManager sharedManager] request_Project_UpdateVisit_WithObj:curPro andBlock:^(id dataTemp, NSError *errorTemp) {
142+
}];
143+
[weakSelf gotoPro:curPro];
144+
}
132145
}
133146
self.submitButtonItem.enabled = YES;
134147
}];
@@ -164,23 +177,13 @@ -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange
164177
}
165178

166179
#pragma mark gotoVC
167-
- (void)gotoProWithStr:(NSString *)data{
168-
NSString *projectRegexStr = @"/u/([^/]+)/p/([^/]+)";
169-
NSArray *matchedCaptures = [data captureComponentsMatchedByRegex:projectRegexStr];
170-
if (matchedCaptures.count >= 3) {
171-
NSString *user_global_key = matchedCaptures[1];
172-
NSString *project_name = matchedCaptures[2];
173-
Project *curPro = [[Project alloc] init];
174-
curPro.owner_user_name = user_global_key;
175-
curPro.name = project_name;
176-
NProjectViewController *vc = [[NProjectViewController alloc] init];
177-
vc.myProject = curPro;
178-
179-
NSMutableArray *curViewControllers = [NSMutableArray arrayWithArray:[self.navigationController viewControllers]];
180-
if (curViewControllers.count >= 2) {
181-
[curViewControllers replaceObjectAtIndex:curViewControllers.count - 1 withObject:vc];
182-
[self.navigationController setViewControllers:curViewControllers animated:YES];
183-
}
180+
- (void)gotoPro:(Project *)curPro{
181+
NProjectViewController *vc = [[NProjectViewController alloc] init];
182+
vc.myProject = curPro;
183+
NSMutableArray *curViewControllers = [NSMutableArray arrayWithArray:[self.navigationController viewControllers]];
184+
if (curViewControllers.count >= 2) {
185+
[curViewControllers replaceObjectAtIndex:curViewControllers.count - 1 withObject:vc];
186+
[self.navigationController setViewControllers:curViewControllers animated:YES];
184187
}
185188
}
186189

Coding_iOS/Models/Projects.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ - (NSDictionary *)toMembersParams{
180180
@"pageSize" : [NSNumber numberWithInteger:500]};
181181
}
182182
- (NSString *)toUpdateVisitPath{
183-
return [NSString stringWithFormat:@"api/project/%d/update_visit", self.id.intValue];
183+
if (self.owner_user_name.length > 0 && self.name.length > 0) {
184+
return [NSString stringWithFormat:@"api/user/%@/project/%@/update_visit", self.owner_user_name, self.name];
185+
}else{
186+
return [NSString stringWithFormat:@"api/project/%d/update_visit", self.id.intValue];
187+
}
184188
}
185189
- (NSString *)toDetailPath{
186190
return [NSString stringWithFormat:@"api/user/%@/project/%@", self.owner_user_name, self.name];

0 commit comments

Comments
 (0)