Skip to content

Commit 5a389ff

Browse files
authored
Merge pull request #18576 from wordpress-mobile/feature/18523-limit_prompts_list
Blogging Prompts List: limit to 11 prompts, no filtering
2 parents 6430e00 + 9914318 commit 5a389ff

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

WordPress/Classes/Services/BloggingPromptsService.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ class BloggingPromptsService {
4747
}, failure: failure)
4848
}
4949

50+
/// Convenience method to fetch the blogging prompts for the Prompts List.
51+
/// Fetches 11 prompts - the current day and 10 previous.
52+
///
53+
/// - Parameters:
54+
/// - success: Closure to be called when the fetch process succeeded.
55+
/// - failure: Closure to be called when the fetch process failed.
56+
func fetchListPrompts(success: @escaping ([BloggingPrompt]) -> Void,
57+
failure: @escaping (Error?) -> Void) {
58+
let fromDate = calendar.date(byAdding: .day, value: -9, to: Date()) ?? Date()
59+
fetchPrompts(from: fromDate, number: 11, success: success, failure: failure)
60+
}
61+
5062
required init?(context: NSManagedObjectContext = ContextManager.shared.mainContext,
5163
remote: BloggingPromptsServiceRemote? = nil,
5264
blog: Blog? = nil) {

WordPress/Classes/ViewRelated/Blog/Blogging Prompts/BloggingPromptsViewController.storyboard

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2121
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2222
<subviews>
23-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bno-oB-pDf" customClass="FilterTabBar" customModule="WordPress" customModuleProvider="target">
23+
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bno-oB-pDf" customClass="FilterTabBar" customModule="WordPress" customModuleProvider="target">
2424
<rect key="frame" x="0.0" y="0.0" width="375" height="46"/>
2525
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
2626
<constraints>
2727
<constraint firstAttribute="height" constant="46" id="mN2-YL-PRM"/>
2828
</constraints>
2929
</view>
3030
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="7aR-Vp-g6a">
31-
<rect key="frame" x="0.0" y="46" width="375" height="621"/>
31+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
3232
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
3333
<inset key="separatorInset" minX="16" minY="0.0" maxX="0.0" maxY="0.0"/>
3434
<connections>
@@ -41,12 +41,18 @@
4141
<constraints>
4242
<constraint firstItem="bno-oB-pDf" firstAttribute="leading" secondItem="gDw-cc-yIW" secondAttribute="leading" id="7Jf-su-8WM"/>
4343
<constraint firstAttribute="trailing" secondItem="bno-oB-pDf" secondAttribute="trailing" id="AgG-aE-VG8"/>
44+
<constraint firstItem="7aR-Vp-g6a" firstAttribute="top" secondItem="gDw-cc-yIW" secondAttribute="top" id="Ndp-h3-R7q"/>
4445
<constraint firstItem="7aR-Vp-g6a" firstAttribute="leading" secondItem="gDw-cc-yIW" secondAttribute="leading" id="Nt5-JK-DbB"/>
45-
<constraint firstItem="uCp-uQ-tOJ" firstAttribute="top" secondItem="7aR-Vp-g6a" secondAttribute="bottom" id="Oly-V9-tho"/>
46+
<constraint firstAttribute="bottom" secondItem="7aR-Vp-g6a" secondAttribute="bottom" id="Oly-V9-tho"/>
4647
<constraint firstItem="7aR-Vp-g6a" firstAttribute="top" secondItem="bno-oB-pDf" secondAttribute="bottom" id="Rmm-F3-kCp"/>
4748
<constraint firstAttribute="trailing" secondItem="7aR-Vp-g6a" secondAttribute="trailing" id="htA-bQ-QaF"/>
48-
<constraint firstItem="bno-oB-pDf" firstAttribute="top" secondItem="MpO-o7-pbX" secondAttribute="bottom" id="tfA-U7-Sc2"/>
49+
<constraint firstItem="bno-oB-pDf" firstAttribute="top" secondItem="gDw-cc-yIW" secondAttribute="top" id="tfA-U7-Sc2"/>
4950
</constraints>
51+
<variation key="default">
52+
<mask key="constraints">
53+
<exclude reference="Rmm-F3-kCp"/>
54+
</mask>
55+
</variation>
5056
</view>
5157
<connections>
5258
<outlet property="filterTabBar" destination="bno-oB-pDf" id="fxk-Bw-WWL"/>

WordPress/Classes/ViewRelated/Blog/Blogging Prompts/BloggingPromptsViewController.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private extension BloggingPromptsViewController {
116116

117117
isLoading = true
118118

119-
bloggingPromptsService.fetchPrompts(success: { [weak self] (prompts) in
119+
bloggingPromptsService.fetchListPrompts(success: { [weak self] (prompts) in
120120
self?.isLoading = false
121121
self?.prompts = prompts.sorted(by: { $0.date.compare($1.date) == .orderedDescending })
122122
}, failure: { [weak self] (error) in
@@ -164,6 +164,13 @@ extension BloggingPromptsViewController: UITableViewDataSource, UITableViewDeleg
164164

165165
private extension BloggingPromptsViewController {
166166

167+
// For Blogging Prompts V1, there is a single unfiltered prompts list.
168+
// The expectation is it will be filtered at some point. So the FilterTabBar is hidden instead of removed.
169+
// To show it, in the storyboard:
170+
// - Unhide the FilterTabBar.
171+
// - Remove the tableView top constraint to superview.
172+
// - Enable the tableView top constraint to the FilterTabBar bottom.
173+
167174
enum PromptFilter: Int, FilterTabBarItem, CaseIterable {
168175
case all
169176
case answered

0 commit comments

Comments
 (0)