Skip to content

Commit dab3cac

Browse files
wanghenghengEase
authored and
Ease
committed
添加项目内冒泡
1 parent b072690 commit dab3cac

File tree

6 files changed

+91
-25
lines changed

6 files changed

+91
-25
lines changed

Coding_iOS/Controllers/RootControllers/BaseViewController.m

+11
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ + (UIViewController *)analyseVCFromLinkStr:(NSString *)linkStr analyseMethod:(An
148148
NSString *userRegexStr = @"/u/([^/]+)$";
149149
NSString *userTweetRegexStr = @"/u/([^/]+)/bubble$";
150150
NSString *ppRegexStr = @"/u/([^/]+)/pp/([0-9]+)$";
151+
NSString *pp_projectRegexStr = @"/u/([^/]+)/p/([^\?]+)[\?]pp=([0-9]+)$";
151152
NSString *topicRegexStr = @"/u/([^/]+)/p/([^/]+)/topic/(\\d+)";
152153
NSString *taskRegexStr = @"/u/([^/]+)/p/([^/]+)/task/(\\d+)";
153154
NSString *fileRegexStr = @"/u/([^/]+)/p/([^/]+)/attachment/([^/]+)/preview/(\\d+)";
@@ -175,6 +176,16 @@ + (UIViewController *)analyseVCFromLinkStr:(NSString *)linkStr analyseMethod:(An
175176
vc.curTweet = [Tweet tweetWithGlobalKey:user_global_key andPPID:pp_id];
176177
analyseVC = vc;
177178
}
179+
}else if ((matchedCaptures = [linkStr captureComponentsMatchedByRegex:pp_projectRegexStr]).count > 0){
180+
NSString *owner_user_global_key = matchedCaptures[1];
181+
NSString *project_name = matchedCaptures[2];
182+
NSString *pp_id = matchedCaptures[3];
183+
Project *curPro = [Project new];
184+
curPro.owner_user_name = owner_user_global_key;
185+
curPro.name = project_name;
186+
TweetDetailViewController *vc = [[TweetDetailViewController alloc] init];
187+
vc.curTweet = [Tweet tweetInProject:curPro andPPID:pp_id];
188+
analyseVC = vc;
178189
}else if ((matchedCaptures = [linkStr captureComponentsMatchedByRegex:gitMRPRCommitRegexStr]).count > 0){
179190
//MR
180191
NSString *path = [matchedCaptures[0] stringByReplacingOccurrencesOfString:@"https://coding.net" withString:@""];

Coding_iOS/Controllers/TweetDetailViewController.m

+28-13
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,35 @@ - (void)messageInputView:(UIMessageInputView *)inputView heightToBottomChenged:(
163163
#pragma mark refresh
164164
- (void)refreshTweet{
165165
__weak typeof(self) weakSelf = self;
166-
[[Coding_NetAPIManager sharedManager] request_Tweet_Detail_WithObj:_curTweet andBlock:^(id data, NSError *error) {
167-
if (data) {
168-
if (weakSelf.curTweet.contentHeight > 1) {
169-
((Tweet *)data).contentHeight = weakSelf.curTweet.contentHeight;
166+
if (_curTweet.project && !_curTweet.project_id) {
167+
[[Coding_NetAPIManager sharedManager] request_ProjectDetail_WithObj:_curTweet.project andBlock:^(id data, NSError *error) {
168+
if (data) {
169+
weakSelf.curTweet.project = data;
170+
weakSelf.curTweet.project_id = [(Project *)data id];
171+
[weakSelf refreshTweet];
172+
}else{
173+
[weakSelf.refreshControl endRefreshing];
170174
}
171-
weakSelf.curTweet = data;
172-
weakSelf.myMsgInputView.commentOfId = weakSelf.curTweet.id;
173-
weakSelf.myMsgInputView.toUser = nil;
174-
[weakSelf.myTableView reloadData];
175-
[weakSelf refreshComments];
176-
}else{
177-
[weakSelf.refreshControl endRefreshing];
178-
}
179-
}];
175+
}];
176+
}else{
177+
[[Coding_NetAPIManager sharedManager] request_Tweet_Detail_WithObj:_curTweet andBlock:^(id data, NSError *error) {
178+
if (data) {
179+
if (weakSelf.curTweet.contentHeight > 1) {
180+
((Tweet *)data).contentHeight = weakSelf.curTweet.contentHeight;
181+
}
182+
if (weakSelf.curTweet.project) {
183+
[(Tweet *)data setProject:weakSelf.curTweet.project];
184+
}
185+
weakSelf.curTweet = data;
186+
weakSelf.myMsgInputView.commentOfId = weakSelf.curTweet.id;
187+
weakSelf.myMsgInputView.toUser = nil;
188+
[weakSelf.myTableView reloadData];
189+
[weakSelf refreshComments];
190+
}else{
191+
[weakSelf.refreshControl endRefreshing];
192+
}
193+
}];
194+
}
180195
}
181196

182197
- (void)refreshComments{

Coding_iOS/Models/Tweet.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "User.h"
1212
#import "HtmlMedia.h"
1313
#import "TweetSendLocation.h"
14+
#import "Project.h"
1415

1516
@class TweetImage;
1617

@@ -31,7 +32,9 @@
3132
@property (readwrite, nonatomic, strong) NSString *nextCommentStr;
3233
@property (assign, nonatomic) CGFloat contentHeight;
3334

34-
@property (strong, nonatomic) NSString *user_global_key, *pp_id;
35+
@property (strong, nonatomic) NSString *user_global_key;
36+
@property (strong, nonatomic) Project *project;
37+
@property (strong, nonatomic) NSNumber *project_id;
3538

3639
- (void)addASelectedAssetURL:(NSURL *)assetURL;
3740
- (void)deleteASelectedAssetURL:(NSURL *)assetURL;
@@ -65,6 +68,8 @@
6568
+ (void)deleteSendData;
6669

6770
+(Tweet *)tweetWithGlobalKey:(NSString *)user_global_key andPPID:(NSString *)pp_id;
71+
+(Tweet *)tweetInProject:(Project *)project andPPID:(NSString *)pp_id;
72+
6873
- (NSDictionary *)toDoTweetParams;
6974
- (BOOL)isAllImagesHaveDone;
7075
- (void)addNewComment:(Comment *)comment;

Coding_iOS/Models/Tweet.m

+40-10
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ - (NSString *)toDoLikePath{
109109
}
110110

111111
- (NSString *)toDoCommentPath{
112-
NSString *doCommentPath;
113-
doCommentPath = [NSString stringWithFormat:@"api/tweet/%d/comment", self.id.intValue];
114-
return doCommentPath;
112+
if (self.project_id) {
113+
return [NSString stringWithFormat:@"api/project/%@/tweet/%@/comment", self.project_id.stringValue, self.id.stringValue];
114+
}else{
115+
return [NSString stringWithFormat:@"api/tweet/%d/comment", self.id.intValue];
116+
}
115117
}
116118
- (NSDictionary *)toDoCommentParams{
117119
return @{@"content" : [self.nextCommentStr aliasedString]};
@@ -124,21 +126,37 @@ - (NSDictionary *)toLikersParams{
124126
@"pageSize" : [NSNumber numberWithInteger:500]};
125127
}
126128
- (NSString *)toCommentsPath{
127-
return [NSString stringWithFormat:@"api/tweet/%d/comments", _id.intValue];
129+
NSString *path;
130+
if (self.project_id) {
131+
path = [NSString stringWithFormat:@"api/project/%@/tweet/%@/comments", self.project_id.stringValue, self.id.stringValue];
132+
}else{
133+
path = [NSString stringWithFormat:@"api/tweet/%d/comments", _id.intValue];
134+
}
135+
return path;
128136
}
129137
- (NSDictionary *)toCommentsParams{
130138
return @{@"page" : [NSNumber numberWithInteger:1],
131139
@"pageSize" : [NSNumber numberWithInteger:500]};
132140
}
133141
- (NSString *)toDeletePath{
134-
return [NSString stringWithFormat:@"api/tweet/%d", self.id.intValue];
142+
if (self.project_id) {
143+
return [NSString stringWithFormat:@"api/project/%@/tweet/%@", self.project_id.stringValue, self.id.stringValue];
144+
}else{
145+
return [NSString stringWithFormat:@"api/tweet/%d", self.id.intValue];
146+
}
135147
}
136148
- (NSString *)toDetailPath{
137-
if (self.user_global_key && self.pp_id) {
138-
return [NSString stringWithFormat:@"api/tweet/%@/%@", self.user_global_key, self.pp_id];
149+
NSString *path;
150+
if (self.project_id) {
151+
path = [NSString stringWithFormat:@"api/project/%@/tweet/%@", self.project_id.stringValue, self.id.stringValue];
152+
}else if (self.project){
153+
//需要先去获取project_id
154+
}else if (self.user_global_key) {
155+
path = [NSString stringWithFormat:@"api/tweet/%@/%@", self.user_global_key, self.id.stringValue];
139156
}else{
140-
return [NSString stringWithFormat:@"api/tweet/%@/%@", self.owner.global_key, self.id.stringValue];
157+
path = [NSString stringWithFormat:@"api/tweet/%@/%@", self.owner.global_key, self.id.stringValue];
141158
}
159+
return path;
142160
}
143161

144162
+(Tweet *)tweetForSend{
@@ -198,8 +216,14 @@ + (void)deleteSendData{
198216

199217
+(Tweet *)tweetWithGlobalKey:(NSString *)user_global_key andPPID:(NSString *)pp_id{
200218
Tweet *tweet = [[Tweet alloc] init];
219+
tweet.id = [NSNumber numberWithInteger:pp_id.integerValue];
201220
tweet.user_global_key = user_global_key;
202-
tweet.pp_id = pp_id;
221+
return tweet;
222+
}
223+
+(Tweet *)tweetInProject:(Project *)project andPPID:(NSString *)pp_id{
224+
Tweet *tweet = [[Tweet alloc] init];
225+
tweet.id = [NSNumber numberWithInteger:pp_id.integerValue];
226+
tweet.project = project;
203227
return tweet;
204228
}
205229

@@ -251,7 +275,13 @@ - (void)deleteComment:(Comment *)comment{
251275
}
252276

253277
- (NSString *)toShareLinkStr{
254-
return [NSString stringWithFormat:@"%@u/%@/pp/%@", kBaseUrlStr_Phone, _owner.global_key, _id];
278+
NSString *shareLinkStr;
279+
if (_project) {
280+
shareLinkStr = [NSString stringWithFormat:@"%@u/%@/p/%@?pp=%@", [NSObject baseURLStr], _project.owner_user_name, _project.name, _id.stringValue];
281+
}else{
282+
shareLinkStr = [NSString stringWithFormat:@"%@u/%@/pp/%@", kBaseUrlStr_Phone, _owner.global_key, _id];
283+
}
284+
return shareLinkStr;
255285
}
256286

257287
#pragma mark ALAsset

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,9 @@ - (void)request_Tweet_Comments_WithObj:(Tweet *)tweet andBlock:(void (^)(id data
15181518
[MobClick event:kUmeng_Event_Request_Get label:@"冒泡_评论_列表"];
15191519

15201520
id resultData = [data valueForKeyPath:@"data"];
1521-
resultData = [resultData valueForKeyPath:@"list"];
1521+
if ([resultData isKindOfClass:[NSDictionary class]]) {
1522+
resultData = [resultData valueForKeyPath:@"list"];
1523+
}
15221524
NSArray *resultA = [NSObject arrayFromJSON:resultData ofObjects:@"Comment"];
15231525
block(resultA, nil);
15241526
}else{

Coding_iOS/Views/Cell/TweetDetailCell.m

+3
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ - (void)setTweet:(Tweet *)tweet{
175175
if (tweet) {
176176
_tweet = tweet;
177177
}
178+
BOOL isProjectTweet = _tweet.project_id != nil;
179+
self.likeBtn.hidden = isProjectTweet;
180+
self.shareBtn.hidden = isProjectTweet;
178181

179182
//owner头像
180183
__weak __typeof(self)weakSelf = self;

0 commit comments

Comments
 (0)