Skip to content

Commit ce45515

Browse files
committed
https://coding.net/t/codingcorp/p/Coding-iOS/task/815318
1 parent dd58663 commit ce45515

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

Coding_iOS/Controllers/Topic/CSTopicCreateVC.m

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,8 @@ - (void)viewDidLoad {
9696

9797
- (void)refreshHotTopiclist{
9898
__weak typeof(self) wself = self;
99-
[[Coding_NetAPIManager sharedManager] request_HotTopiclistWithBlock:^(NSArray *topiclist, NSError *error) {
100-
if (topiclist) {
101-
NSMutableArray *namelist = [NSMutableArray array];
102-
for (int i=0; i<topiclist.count && i < 10; i++) {
103-
NSDictionary *topicDict = topiclist[i];
104-
[namelist addObject:topicDict[@"name"]];
105-
}
106-
wself.hotTopiclist = [namelist copy];
107-
}else {
108-
wself.hotTopiclist = [NSArray array];
109-
}
99+
[[Coding_NetAPIManager sharedManager] request_DefautsHotTopicNamelistWithBlock:^(NSArray *nameList, NSError *error) {
100+
wself.hotTopiclist = nameList.count > 10? [nameList subarrayWithRange:NSMakeRange(0, 10)]: nameList;
110101
[wself.listView reloadData];
111102
}];
112103
}

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ typedef NS_ENUM(NSInteger, PurposeType) {
254254
#pragma mark - Topic
255255
- (void)request_TopicAdlistWithBlock:(void (^)(id data, NSError *error))block;
256256
- (void)request_HotTopiclistWithBlock:(void (^)(id data, NSError *error))block;
257-
257+
- (void)request_DefautsHotTopicNamelistWithBlock:(void (^)(id data, NSError *error))block;
258258
- (void)request_Tweet_WithSearchString:(NSString *)strSearch andPage:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block;
259259

260260
- (void)requestWithSearchString:(NSString *)strSearch typeStr:(NSString*)type andPage:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block;

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,6 +2560,29 @@ - (void)request_HotTopiclistWithBlock:(void (^)(id data, NSError *error))block {
25602560
}];
25612561
}
25622562

2563+
- (void)request_DefautsHotTopicNamelistWithBlock:(void (^)(id data, NSError *error))block {
2564+
NSString *defaultsPath = @"api/tweet_topic/defaults";
2565+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:defaultsPath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
2566+
if (data) {
2567+
NSMutableArray *resultList = [[data[@"data"] valueForKey:@"name"] mutableCopy];
2568+
NSString *hotPath = @"/api/tweet_topic/hot";
2569+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:hotPath withParams:nil withMethodType:Get andBlock:^(id dataHot, NSError *errorHot) {
2570+
if (dataHot) {
2571+
[MobClick event:kUmeng_Event_Request_Get label:@"话题_热门话题_榜单"];
2572+
NSMutableArray *hotList = [[dataHot[@"data"] valueForKey:@"name"] mutableCopy];
2573+
[hotList removeObjectsInArray:resultList];//剔除重复元素
2574+
[resultList addObjectsFromArray:hotList];//将 hot 追加到 defaults 末尾
2575+
block(resultList, nil);
2576+
}else{
2577+
block(nil, errorHot);
2578+
}
2579+
}];
2580+
}else{
2581+
block(nil, error);
2582+
}
2583+
}];
2584+
}
2585+
25632586
- (void)request_Tweet_WithSearchString:(NSString *)strSearch andPage:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block {
25642587

25652588
NSString *path = [NSString stringWithFormat:@"/api/search/quick?q=%@&page=%d", strSearch, (int)page];

0 commit comments

Comments
 (0)