Add homepage / posts page setting functionality - #14209
Conversation
|
You can trigger an installable build for these changes by visiting CircleCI here. |
|
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
|
cc @SylvesterWilmott is this slight tweak to the posts / homepage picker okay with you? I think it's nice to have search in there, and a pragmatic way to get this shipped faster :) |
frosty
left a comment
There was a problem hiding this comment.
Looking good, and works fine for me when testing it out. I left some small code cleanup suggestions.
One thing missing here from the designs is that ideally a page you've already selected for one of the settings shouldn't show up in the other setting's picker. We could address this in a followup PR if that's easier?
| } | ||
| } | ||
| if post.permaLink == selectedLink { | ||
| if isSelectedPost?(post) == true { |
There was a problem hiding this comment.
Could omit the == true here
There was a problem hiding this comment.
The block is optional here so it needs something like == true or isSelectedPost?(post) ?? false.
| homepageRow = ActivityIndicatorRow(title: Strings.homepage, animating: true, action: nil) | ||
| } else { | ||
| homepageRow = NavigationItemRow(title: Strings.homepage, detail: homepageTitle, action: { _ in | ||
| self.pushPageSelection(selectedPostID: self.blog?.homepagePageID) { [weak self] selected in |
There was a problem hiding this comment.
Could we extract the contents of this action to another method or something to make it a little clearer to follow? Also, should this self be weak?
| } | ||
|
|
||
| // MARK: - Updating Settings | ||
| open override func viewWillAppear(_ animated: Bool) { |
There was a problem hiding this comment.
Can we move this up below viewDidLoad?
| let viewController = SelectPostViewController(blog: blog, | ||
| isSelectedPost: { $0.postID?.intValue == selectedPostID }, | ||
| showsPostType: false, | ||
| entityName: Page.entityName()) { (post) in |
There was a problem hiding this comment.
Can we keep the trailing closure name? I think it might just be a little easier to understand what the closure's for.
| if let page = post as? Page { | ||
| completion(page) | ||
| } | ||
| self.navigationController?.popViewController(animated: true) |
|
@frosty I totally missed that! It should be easy enough to add to this. |
frosty
left a comment
There was a problem hiding this comment.
Looking good! Scenarios 5, 6, 7, and 8 are working as expected for me. I did find one issue related to bad / slow connectivity. It's easiest to see if you use Network Link Conditioner set to very bad network:
- Go to the Homepage Settings screen, with it set to Static Homepage
- Tap one of the rows and choose a page
- While the loading indicator is still spinning for that row, go and select a page for the other row
- Your second selection won't 'stick' – the cell will still show the original page name while the first one continues loading.
| } | ||
|
|
||
| func posts(for blog: Blog, containsTitle title: String, entityName: String? = nil) -> NSFetchedResultsController<AbstractPost> { | ||
| func posts(for blog: Blog, containsTitle title: String, entityName: String? = nil, excludingPostIDs excludedPostIDs: [Int] = []) -> NSFetchedResultsController<AbstractPost> { |
There was a problem hiding this comment.
I'd be tempted to switch around the order here so that containsTitle and excludingPostIDs are grouped together. So entityName should either go second or last. What do you think?
| if !title.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty { | ||
| compoundPredicates.append(NSPredicate(format: "postTitle contains[c] %@", title)) | ||
| } | ||
| compoundPredicates.append(NSPredicate(format: "NOT (postID IN %@)", excludedPostIDs)) |
There was a problem hiding this comment.
Should we only add this if excludedPostIDs contains some items?
There was a problem hiding this comment.
I thought about that, I figured it doesn't matter much if the array is empty but it's probably a theoretical performance improvement.
|
Looks great! Thanks @bjtitus |
|
@frosty Fixed that bad network issue by just disabling selection on the table view. If that seems like a bad idea, I also considered allowing selection but immediately deselecting the cell and not performing the action (just so there's some intractability left for the user). I'm not quite sure which one seems less confusing – let me know what you think. |
frosty
left a comment
There was a problem hiding this comment.
I think the current solution works fine – thanks for making that change! I've just added a code-level comment about a bug I spotted, and the last thing that I can see is that the activity indicator in the rows is currently super hard to see in dark mode. I'm surprised it doesn't change automatically – perhaps we need to tint it to a system color.
| return ActivityIndicatorRow(title: title, animating: true, action: nil) | ||
| } else { | ||
| return NavigationItemRow(title: title, detail: detail, action: { [weak self] _ in | ||
| self?.showPageSelection(selectedPostID: self?.blog?.homepagePageID, hiddenPostID: self?.blog?.homepagePostsPageID, change: changeForPost) |
There was a problem hiding this comment.
We're always passing homepageID for the selected post, and postPageID for the hidden post ID here, so the picker shown the same content no matter which row you're tapping into. These should be switched for the Posts row.
frosty
left a comment
There was a problem hiding this comment.
Looks great! Activity indicator now visible in dark mode, and the correct page is hidden for each of posts / pages.
I'll go ahead and merge this ahead of the freeze on Monday.
Ref #14167
This reuses the
SelectPostViewControllerfor selecting a post for the Homepage Settings functionality.Note that this design is slightly different than the original issue. I wanted to reuse the same view controller we use for selecting a post for links and this view controller also includes search, which seems like a nice feature addition. If the grouped table style is necessary, I can adjust that style for this particular presentation.
Testing
All scenarios from #14169 should continue to work. The following represent several new scenarios to test:
Scenario 5
Scenario 6
Scenario 7
Scenario 8
This is to verify existing functionality which also used
SelectPostViewControllerPR submission checklist:
RELEASE-NOTES.txtif necessary.