Commit 87d8b793 authored by Ewann's avatar Ewann Committed by Commit Bot

Fix headers on reading list after deleting articles.

-call |-removeEmptySections| in |-setEditing:animated:| before resetting the property.

needsSectionCleanupAfterEditing needs to be removed when dropping iOS 12.

Bug: 998491
Change-Id: I38cef305e1763120b402f1904f21c29c48ce024a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832273Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703237}
parent 1631452b
......@@ -83,6 +83,7 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
// Whether the table view is being edited by the swipe-to-delete button.
@property(nonatomic, readonly, getter=isEditingWithSwipe) BOOL editingWithSwipe;
// Whether to remove empty sections after editing is reset to NO.
// TODO (crbug.com/1010836): remove when dropping iOS 12.
@property(nonatomic, assign) BOOL needsSectionCleanupAfterEditing;
@end
......@@ -138,6 +139,7 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
if (!editing) {
self.editingWithToolbarButtons = NO;
if (self.needsSectionCleanupAfterEditing) {
[self removeEmptySections];
self.needsSectionCleanupAfterEditing = NO;
}
}
......@@ -241,15 +243,22 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
forRowAtIndexPath:(NSIndexPath*)indexPath {
DCHECK_EQ(editingStyle, UITableViewCellEditingStyleDelete);
base::RecordAction(base::UserMetricsAction("MobileReadingListDeleteEntry"));
// The UIKit animation for the swipe-to-delete gesture throws an exception if
// the section of the deleted item is removed before the animation is
// finished. To prevent this from happening, record that cleanup is needed
// and remove the section when self.tableView.editing is reset to NO when the
// animation finishes.
self.needsSectionCleanupAfterEditing = YES;
[self deleteItemsAtIndexPaths:@[ indexPath ]
endEditing:NO
removeEmptySections:NO];
if (@available(iOS 13, *)) {
[self deleteItemsAtIndexPaths:@[ indexPath ]
endEditing:YES
removeEmptySections:YES];
} else {
// On IOS 12, the UIKit animation for the swipe-to-delete gesture throws an
// exception if the section of the deleted item is removed before the
// animation is finished. To prevent this from happening, record that
// cleanup is needed and remove the section when self.tableView.editing is
// reset to NO when the animation finishes.
self.needsSectionCleanupAfterEditing = YES;
[self deleteItemsAtIndexPaths:@[ indexPath ]
endEditing:NO
removeEmptySections:NO];
}
}
#pragma mark - UITableViewDelegate
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment