Skip to content

Commit

Permalink
Merge pull request #16130 from wordpress-mobile/feature/16110-comment…
Browse files Browse the repository at this point in the history
…s_group_by_day

Comments: group by date created
  • Loading branch information
ScoutHarris authored Mar 18, 2021
2 parents abeaa3d + d174022 commit 99a8866
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 4 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [*] Reader: fixed an issue that caused unfollowing external sites to fail. [#16060]
* [*] Stats: fixed an issue where an error was displayed for Latest Post Summary if the site had no posts. [#16074]
* [*] Fixed an issue where password text on Post Settings was showing as black in dark mode. [#15768]
* [**] Comments can now be filtered by status (All, Pending, Approved, Trashed, or Spam). [#15955, #16110]

16.9
-----
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Models/Comment.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ extern NSString * const CommentStatusDraft;
- (NSString *)authorUrlForDisplay;
- (BOOL)hasAuthorUrl;
- (BOOL)isApproved;
- (NSString *)sectionIdentifier;

@end
8 changes: 8 additions & 0 deletions WordPress/Classes/Models/Comment.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ - (NSDate *)dateCreated
return date;
}

- (NSString *)sectionIdentifier
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateStyle = NSDateFormatterLongStyle;
formatter.timeStyle = NSDateFormatterNoStyle;
return [formatter stringFromDate:self.dateCreated];
}


#pragma mark - PostContentProvider protocol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag {
case .milestoneNotifications:
return false
case .commentFilters:
return BuildConfiguration.current ~= [.localDeveloper, .a8cBranchTest]
return true
case .newLikeNotifications:
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ open class CommentsTableViewCell: WPTableViewCell {
@IBOutlet private weak var gravatarImageView: CircularImageView!
@IBOutlet private weak var titleLabel: UILabel!
@IBOutlet private weak var detailLabel: UILabel!

@IBOutlet weak var timestampStackView: UIStackView!
@IBOutlet private weak var timestampImageView: UIImageView!
@IBOutlet private weak var timestampLabel: UILabel!

Expand Down Expand Up @@ -101,11 +103,15 @@ private extension CommentsTableViewCell {
}

func configureTimestamp() {

// When FeatureFlag.commentFilters is removed,
// all timestamp elements can be removed.
timestampStackView.isHidden = FeatureFlag.commentFilters.enabled

timestampLabel.text = timestamp
timestampLabel.font = Style.timestampFont
timestampLabel.textColor = Style.detailTextColor
timestampImageView.image = Style.timestampImage

}

func attributedTitle() -> NSAttributedString {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<outlet property="pendingIndicatorWidthConstraint" destination="WeL-cC-lqa" id="NGZ-2z-ehN"/>
<outlet property="timestampImageView" destination="rcg-tb-060" id="cp9-u0-P57"/>
<outlet property="timestampLabel" destination="bDl-id-9M7" id="sk9-hl-b6r"/>
<outlet property="timestampStackView" destination="dIK-tl-nW4" id="3n0-tf-xMe"/>
<outlet property="titleLabel" destination="Wrp-Wr-ZBq" id="lVi-a7-Ppp"/>
</connections>
<point key="canvasLocation" x="33.600000000000001" y="70.614692653673174"/>
Expand Down
27 changes: 25 additions & 2 deletions WordPress/Classes/ViewRelated/Comments/CommentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{

// When FeatureFlagCommentFilters is removed, this whole method can be removed
// and just let WPTableViewHandler provide the height.

if ([Feature enabled:FeatureFlagCommentFilters]) {
return UITableViewAutomaticDimension;
}

// Override WPTableViewHandler's default of UITableViewAutomaticDimension,
// which results in 30pt tall headers on iOS 11
return 0;
Expand Down Expand Up @@ -347,9 +355,16 @@ - (NSFetchRequest *)fetchRequest
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"(blog == %@ AND status != %@)", self.blog, CommentStatusSpam];
}

NSSortDescriptor *sortDescriptorStatus = [NSSortDescriptor sortDescriptorWithKey:@"status" ascending:NO];

NSSortDescriptor *sortDescriptorDate = [NSSortDescriptor sortDescriptorWithKey:@"dateCreated" ascending:NO];
fetchRequest.sortDescriptors = @[sortDescriptorStatus, sortDescriptorDate];

if ([Feature enabled:FeatureFlagCommentFilters]) {
fetchRequest.sortDescriptors = @[sortDescriptorDate];
} else {
NSSortDescriptor *sortDescriptorStatus = [NSSortDescriptor sortDescriptorWithKey:@"status" ascending:NO];
fetchRequest.sortDescriptors = @[sortDescriptorStatus, sortDescriptorDate];
}

fetchRequest.fetchBatchSize = CommentsFetchBatchSize;

return fetchRequest;
Expand All @@ -375,6 +390,14 @@ - (void)deletingSelectedRowAtIndexPath:(NSIndexPath *)indexPath
[self.navigationController popToViewController:self animated:YES];
}

- (NSString *)sectionNameKeyPath
{
if ([Feature enabled:FeatureFlagCommentFilters]) {
return @"sectionIdentifier";
}

return nil;
}

#pragma mark - WPContentSyncHelper Methods

Expand Down

0 comments on commit 99a8866

Please sign in to comment.