Skip to content

Commit

Permalink
Remove attention and favorite api
Browse files Browse the repository at this point in the history
  • Loading branch information
Aufree committed Aug 28, 2016
1 parent 81af23e commit 4d97cca
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 154 deletions.
7 changes: 1 addition & 6 deletions PHPHub/Apis/TopicApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@
- (id)getJobTopicList:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getWiKiList:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getFavoriteTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getAttentionTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getVotedTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getTopicById:(NSInteger)topicId callback:(BaseResultBlock)block;
- (id)addCommentToTopic:(CommentEntity *)comment withBlock:(BaseResultBlock)block;
- (id)favoriteTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)cancelFavoriteTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)attentionTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)cancelAttentionTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)createTopic:(TopicEntity *)entity withBlock:(BaseResultBlock)block;
- (id)voteUpTopic:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)voteDownTopic:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
Expand Down
31 changes: 2 additions & 29 deletions PHPHub/Apis/TopicApi.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,8 @@ - (id)getTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPag
return [self getTopicListByUrlPath:urlPath block:block];
}

- (id)getFavoriteTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex {
NSString *urlPath = [NSString stringWithFormat:@"user/%ld/favorite/topics?include=category,last_reply_user,user&per_page=20&page=%ld"
, (long)userId, (long)pageIndex];

return [self getTopicListByUrlPath:urlPath block:block];
}

- (id)getAttentionTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex {
NSString *urlPath = [NSString stringWithFormat:@"user/%ld/attention/topics?include=category,last_reply_user,user&per_page=20&page=%ld"
- (id)getVotedTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex {
NSString *urlPath = [NSString stringWithFormat:@"user/%ld/votes?include=category,last_reply_user,user&per_page=20&page=%ld"
, (long)userId, (long)pageIndex];

return [self getTopicListByUrlPath:urlPath block:block];
Expand Down Expand Up @@ -133,26 +126,6 @@ - (id)addCommentToTopic:(CommentEntity *)comment withBlock:(BaseResultBlock)bloc
failure:failureBlock];
}

- (id)favoriteTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
NSString *urlString = [NSString stringWithFormat:@"topics/%@/favorite", topicId];
return [self topicAction:topicId withBlock:block urlString:urlString deleteAction:NO];
}

- (id)cancelFavoriteTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
NSString *urlString = [NSString stringWithFormat:@"topics/%@/favorite", topicId];
return [self topicAction:topicId withBlock:block urlString:urlString deleteAction:YES];
}

- (id)attentionTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
NSString *urlString = [NSString stringWithFormat:@"topics/%@/attention", topicId];
return [self topicAction:topicId withBlock:block urlString:urlString deleteAction:NO];
}

- (id)cancelAttentionTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
NSString *urlString = [NSString stringWithFormat:@"topics/%@/attention", topicId];
return [self topicAction:topicId withBlock:block urlString:urlString deleteAction:YES];
}

- (id)voteUpTopic:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
NSString *urlString = [NSString stringWithFormat:@"topics/%@/vote-up", topicId];
return [self topicAction:topicId withBlock:block urlString:urlString deleteAction:NO];
Expand Down
5 changes: 2 additions & 3 deletions PHPHub/Controllers/Forum/TopicListViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ typedef NS_ENUM(NSInteger, TopicListType) {
TopicListTypeHots = 1,
TopicListTypeNoReply = 2,
TopicListTypeJob = 3,
TopicListTypeFavorite = 4,
TopicListTypeAttention = 5,
TopicListTypeNormal = 6,
TopicListTypeVoted = 4,
TopicListTypeNormal = 5,
};

@interface TopicListViewController : UIViewController
Expand Down
9 changes: 3 additions & 6 deletions PHPHub/Controllers/Forum/TopicListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,9 @@ - (void)fetchDataSource:(BaseResultBlock)callback atPage:(NSUInteger)atPage {
} else if (self.topicListType == TopicListTypeJob) {
[[TopicModel Instance] getJobTopicList:callback atPage:atPage];
self.navigationItem.title = @"招聘帖子";
} else if (self.topicListType == TopicListTypeFavorite && self.userId > 0) {
[[TopicModel Instance] getFavoriteTopicListByUser:self.userId callback:callback atPage:atPage];
self.navigationItem.title = @"收藏的帖子";
} else if (self.topicListType == TopicListTypeAttention && self.userId > 0) {
[[TopicModel Instance] getAttentionTopicListByUser:self.userId callback:callback atPage:atPage];
self.navigationItem.title = @"关注的帖子";
} else if (self.topicListType == TopicListTypeVoted && self.userId > 0) {
[[TopicModel Instance] getVotedTopicListByUser:self.userId callback:callback atPage:atPage];
self.navigationItem.title = @"赞过的帖子";
} else if (self.topicListType == TopicListTypeNormal && self.userId > 0) {
[[TopicModel Instance] getTopicListByUser:self.userId callback:callback atPage:atPage];
self.navigationItem.title = @"发布的帖子";
Expand Down
5 changes: 1 addition & 4 deletions PHPHub/Controllers/Me/MeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
vc = notificationListVC;
break;
} case 1: {
vc = [self createTopicListWithType:TopicListTypeAttention];
break;
} case 2: {
vc = [self createTopicListWithType:TopicListTypeFavorite];
vc = [self createTopicListWithType:TopicListTypeVoted];
break;
}
}
Expand Down
5 changes: 1 addition & 4 deletions PHPHub/Controllers/User/UserProfileViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[self jumpToCommentListView];
break;
case 2:
vc = [self createTopicListWithType:TopicListTypeAttention];
break;
case 3:
vc = [self createTopicListWithType:TopicListTypeFavorite];
vc = [self createTopicListWithType:TopicListTypeVoted];
break;

default:
Expand Down
7 changes: 1 addition & 6 deletions PHPHub/Models/TopicModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@
- (id)getJobTopicList:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getWiKiList:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getFavoriteTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getAttentionTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getVotedTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex;
- (id)getTopicById:(NSInteger)topicId callback:(BaseResultBlock)block;
- (id)addCommentToTopic:(CommentEntity *)comment withBlock:(BaseResultBlock)block;
- (id)favoriteTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)cancelFavoriteTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)attentionTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)cancelAttentionTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)createTopic:(TopicEntity *)entity withBlock:(BaseResultBlock)block;
- (id)voteUpTopic:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
- (id)voteDownTopic:(NSNumber *)topicId withBlock:(BaseResultBlock)block;
Expand Down
24 changes: 2 additions & 22 deletions PHPHub/Models/TopicModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ - (id)getTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPag
return [_api getTopicListByUser:userId callback:block atPage:pageIndex];
}

- (id)getFavoriteTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex {
return [_api getFavoriteTopicListByUser:userId callback:block atPage:pageIndex];
}

- (id)getAttentionTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex {
return [_api getAttentionTopicListByUser:userId callback:block atPage:pageIndex];
- (id)getVotedTopicListByUser:(NSInteger)userId callback:(BaseResultBlock)block atPage:(NSInteger)pageIndex {
return [_api getVotedTopicListByUser:userId callback:block atPage:pageIndex];
}

- (id)getTopicById:(NSInteger)topicId callback:(BaseResultBlock)block {
Expand All @@ -66,22 +62,6 @@ - (id)addCommentToTopic:(CommentEntity *)comment withBlock:(BaseResultBlock)bloc
return [_api addCommentToTopic:comment withBlock:block];
}

- (id)favoriteTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
return [_api favoriteTopicById:topicId withBlock:block];
}

- (id)cancelFavoriteTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
return [_api cancelFavoriteTopicById:topicId withBlock:block];
}

- (id)attentionTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
return [_api attentionTopicById:topicId withBlock:block];
}

- (id)cancelAttentionTopicById:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
return [_api cancelAttentionTopicById:topicId withBlock:block];
}

- (id)voteUpTopic:(NSNumber *)topicId withBlock:(BaseResultBlock)block {
return [_api voteUpTopic:topicId withBlock:block];
}
Expand Down
2 changes: 0 additions & 2 deletions PHPHub/Utils/Entities/TopicEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
@property (nonatomic, strong) CategoryEntity *category;
@property (nonatomic, copy) NSString *topicContentUrl;
@property (nonatomic, copy) NSString *topicRepliesUrl;
@property (nonatomic, assign) BOOL favorite;
@property (nonatomic, assign) BOOL attention;
@property (nonatomic, assign) BOOL voteUp;
@property (nonatomic, assign) BOOL voteDown;
@property (nonatomic, strong) NSDate *updatedAt;
Expand Down
2 changes: 0 additions & 2 deletions PHPHub/Utils/Entities/TopicEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ + (NSDictionary *)JSONKeyPathsByPropertyKey {
@"category" : @"category.data",
@"topicContentUrl" : @"links.details_web_view",
@"topicRepliesUrl" : @"links.replies_web_view",
@"favorite" : @"favorite",
@"attention" : @"attention",
@"voteUp" : @"vote_up",
@"voteDown" : @"vote_down",
@"updatedAt" : @"updated_at",
Expand Down
44 changes: 5 additions & 39 deletions PHPHub/Views/Me/Me.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -113,41 +113,8 @@
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" rowHeight="42" id="wY4-ka-GwG">
<rect key="frame" x="0.0" y="246" width="320" height="42"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="wY4-ka-GwG" id="gh8-P9-CLi">
<rect key="frame" x="0.0" y="0.0" width="287" height="42"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="watch_icon" translatesAutoresizingMaskIntoConstraints="NO" id="SxQ-Qq-OZs">
<rect key="frame" x="20" y="8" width="25" height="25"/>
<constraints>
<constraint firstAttribute="height" constant="25" id="T1s-r9-AnF"/>
<constraint firstAttribute="width" constant="25" id="YNy-53-aw9"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="我的关注" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ahK-QN-Bfv">
<rect key="frame" x="75" y="10" width="212" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="6tH-Xk-fBq"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.65490196079999996" green="0.65490196079999996" blue="0.65490196079999996" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="ahK-QN-Bfv" firstAttribute="leading" secondItem="SxQ-Qq-OZs" secondAttribute="trailing" constant="30" id="9LK-3E-1uR"/>
<constraint firstItem="SxQ-Qq-OZs" firstAttribute="leading" secondItem="gh8-P9-CLi" secondAttribute="leadingMargin" constant="12" id="GFu-qE-z4a"/>
<constraint firstItem="ahK-QN-Bfv" firstAttribute="top" secondItem="gh8-P9-CLi" secondAttribute="topMargin" constant="2" id="MIZ-pp-yjs"/>
<constraint firstItem="SxQ-Qq-OZs" firstAttribute="top" secondItem="gh8-P9-CLi" secondAttribute="topMargin" id="aP4-0a-aKw"/>
<constraint firstAttribute="trailing" secondItem="ahK-QN-Bfv" secondAttribute="trailing" id="cxS-3t-U7H"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" rowHeight="42" id="XdQ-u0-zck">
<rect key="frame" x="0.0" y="288" width="320" height="42"/>
<rect key="frame" x="0.0" y="246" width="320" height="42"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="XdQ-u0-zck" id="8AK-c6-Skq">
<rect key="frame" x="0.0" y="0.0" width="287" height="42"/>
Expand All @@ -160,7 +127,7 @@
<constraint firstAttribute="height" constant="25" id="leW-aR-dEb"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="我的收藏" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1jM-WK-tP8">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="赞过的帖子" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1jM-WK-tP8">
<rect key="frame" x="75" y="10" width="212" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="dWb-Gb-ucY"/>
Expand All @@ -184,7 +151,7 @@
<tableViewSection id="LSR-IX-G7V">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" rowHeight="42" id="Woi-mA-Wvc">
<rect key="frame" x="0.0" y="350" width="320" height="42"/>
<rect key="frame" x="0.0" y="308" width="320" height="42"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Woi-mA-Wvc" id="eQI-hH-Syl">
<rect key="frame" x="0.0" y="0.0" width="287" height="42"/>
Expand Down Expand Up @@ -217,7 +184,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" rowHeight="42" id="iBm-BF-Cie">
<rect key="frame" x="0.0" y="392" width="320" height="42"/>
<rect key="frame" x="0.0" y="350" width="320" height="42"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="iBm-BF-Cie" id="sCh-kY-ItX">
<rect key="frame" x="0.0" y="0.0" width="287" height="42"/>
Expand Down Expand Up @@ -250,7 +217,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" rowHeight="42" id="aSj-Xq-6fo">
<rect key="frame" x="0.0" y="434" width="320" height="42"/>
<rect key="frame" x="0.0" y="392" width="320" height="42"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="aSj-Xq-6fo" id="1ja-6d-mcw">
<rect key="frame" x="0.0" y="0.0" width="287" height="42"/>
Expand Down Expand Up @@ -329,6 +296,5 @@
<image name="ring_icon" width="17" height="19"/>
<image name="settings_icon" width="18" height="18"/>
<image name="topic_icon" width="17" height="14"/>
<image name="watch_icon" width="23" height="15"/>
</resources>
</document>
Loading

0 comments on commit 4d97cca

Please sign in to comment.