Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader Post Details: fetch 2 top level comments #17546

Merged
merged 6 commits into from
Nov 24, 2021

Conversation

ScoutHarris
Copy link
Contributor

@ScoutHarris ScoutHarris commented Nov 23, 2021

Ref: #17511

This fetches the post's comments and provides them to the comment table delegate.

  • syncHierarchicalComments fetches the comments and updates Core Data.
  • topLevelComments gets the cached comments.
  • updateComments passes the comments and total comment count to ReaderDetailCommentsTableViewDelegate.

The comments are not displayed yet, but the number of rows in the empty table should correspond to the number of comments, plus one for the button row. (i.e. there will be a minimum of 1 row, and a maximum of 3)

To test:

  • Enable the postDetailsComments feature.
  • Go to Reader and select a post without comments.
    • Verify an empty table is shown with one row (0 comment rows + button row).
  • Select a post with more than 2 top level comments.
    • Verify an empty table is shown with three rows (2 comment rows + button row).

Regression Notes

  1. Potential unintended areas of impact
    N/A. WIP.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    N/A. WIP.

  3. What automated tests I added (or what prevented me from doing so)
    N/A. WIP.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Nov 23, 2021

You can trigger an installable build for these changes by visiting CircleCI here.

@ScoutHarris ScoutHarris requested a review from dvdchr November 24, 2021 00:06
@ScoutHarris ScoutHarris marked this pull request as ready for review November 24, 2021 00:06
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Nov 24, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

Copy link
Contributor

@dvdchr dvdchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments, and the rest is LGTM! :shipit:

@@ -103,10 +103,13 @@ extern NSUInteger const WPTopLevelHierarchicalCommentsPerPage;

// Sync a list of comments sorted by hierarchy, restricted by the specified number of _top level_ comments.
- (void)syncHierarchicalCommentsForPost:(ReaderPost *)post
numberTopLevelComments:(NSUInteger)number
topLevelComments:(NSUInteger)number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nitpick here but I think this needs one more tab for alignment 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@@ -1195,6 +1195,13 @@ - (NSArray *)topLevelCommentsForPage:(NSUInteger)page forPost:(ReaderPost *)post
return fetchedObjects;
}

- (NSArray *)topLevelComments:(NSUInteger)number forPost:(ReaderPost *)post
{
NSArray *comments = [self topLevelCommentsForPage:1 forPost:post];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is out of scope and we're only going to pass in 2 here for the comments below post; But since this is a public method, the implementation could be misleading as it only returns comments from page 1.

Should the method also fetch comments from page 2 (or more) in case if there are comments on the next pages and the number is not yet fulfilled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are existing methods to get more comments with correct pagination, I purposefully restricted the new ones to page 1 since they are intended to get a minimal number of comments. But you make a good point - it is not clear. So instead of expanding them to allow multiple pages, I added comments noting that they are intentionally restricted to page 1.

Comment on lines 197 to 199
commentService.syncHierarchicalComments(for: post,
topLevelComments: commentsDisplayed,
success: { [weak self] _, totalComments in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to be fixed here, just wanted to point out yet another little Xcode 13 bug. The IDE recognizes for as a for-loop syntax instead of a method parameter, and it misaligns the other parameters on the next lines 😅 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IDE recognizes for as a for-loop syntax

Well of course it did. 😆 Thanks!

@ScoutHarris ScoutHarris merged commit 34fd2b2 into develop Nov 24, 2021
@ScoutHarris ScoutHarris deleted the feature/17511-fetch_comments branch November 24, 2021 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants