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( ...@@ -83,6 +83,7 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
// Whether the table view is being edited by the swipe-to-delete button. // Whether the table view is being edited by the swipe-to-delete button.
@property(nonatomic, readonly, getter=isEditingWithSwipe) BOOL editingWithSwipe; @property(nonatomic, readonly, getter=isEditingWithSwipe) BOOL editingWithSwipe;
// Whether to remove empty sections after editing is reset to NO. // 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; @property(nonatomic, assign) BOOL needsSectionCleanupAfterEditing;
@end @end
...@@ -138,6 +139,7 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts( ...@@ -138,6 +139,7 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
if (!editing) { if (!editing) {
self.editingWithToolbarButtons = NO; self.editingWithToolbarButtons = NO;
if (self.needsSectionCleanupAfterEditing) { if (self.needsSectionCleanupAfterEditing) {
[self removeEmptySections];
self.needsSectionCleanupAfterEditing = NO; self.needsSectionCleanupAfterEditing = NO;
} }
} }
...@@ -241,15 +243,22 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts( ...@@ -241,15 +243,22 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
forRowAtIndexPath:(NSIndexPath*)indexPath { forRowAtIndexPath:(NSIndexPath*)indexPath {
DCHECK_EQ(editingStyle, UITableViewCellEditingStyleDelete); DCHECK_EQ(editingStyle, UITableViewCellEditingStyleDelete);
base::RecordAction(base::UserMetricsAction("MobileReadingListDeleteEntry")); 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 if (@available(iOS 13, *)) {
// finished. To prevent this from happening, record that cleanup is needed [self deleteItemsAtIndexPaths:@[ indexPath ]
// and remove the section when self.tableView.editing is reset to NO when the endEditing:YES
// animation finishes. removeEmptySections:YES];
self.needsSectionCleanupAfterEditing = YES; } else {
[self deleteItemsAtIndexPaths:@[ indexPath ] // On IOS 12, the UIKit animation for the swipe-to-delete gesture throws an
endEditing:NO // exception if the section of the deleted item is removed before the
removeEmptySections:NO]; // 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 #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