Skip to content

Commit

Permalink
Fix broken animations (#23807)
Browse files Browse the repository at this point in the history
  • Loading branch information
kean authored Nov 15, 2024
1 parent d86215d commit b20381f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions WordPress/Classes/Utility/WPTableViewHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
@property (nonatomic) UITableViewRowAnimation moveRowAnimation;
@property (nonatomic) UITableViewRowAnimation sectionRowAnimation;
@property (nonatomic) BOOL listensForContentChanges;
@property (nonatomic) BOOL disableAnimations;

- (nonnull instancetype)initWithTableView:(nonnull UITableView *)tableView;
- (void)clearCachedRowHeights;
Expand Down
8 changes: 7 additions & 1 deletion WordPress/Classes/Utility/WPTableViewHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ - (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
}

self.indexPathSelectedBeforeUpdates = [self.tableView indexPathForSelectedRow];
if (self.disableAnimations) {
[UIView setAnimationsEnabled:NO];
}
[self.tableView beginUpdates];
}

Expand All @@ -645,6 +648,9 @@ - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
NSError *error;
[WPException objcTryBlock:^{
[self.tableView endUpdates];
if (self.disableAnimations) {
[UIView setAnimationsEnabled:YES];
}
} error:&error];

if (error) {
Expand Down Expand Up @@ -697,7 +703,7 @@ - (void)controller:(NSFetchedResultsController *)controller
// It seems in some cases newIndexPath can be nil for updates
newIndexPath = indexPath;
}

switch(type) {
case NSFetchedResultsChangeInsert:
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ final class ReaderTableContent {
private var tableViewHandler: WPTableViewHandler?

func initializeContent(tableView: UITableView, delegate: WPTableViewHandlerDelegate) {
tableViewHandler = WPTableViewHandler(tableView: tableView)
tableViewHandler?.cacheRowHeights = false
tableViewHandler?.updateRowAnimation = .none
tableViewHandler?.delegate = delegate
let tableViewHandler = WPTableViewHandler(tableView: tableView)
tableViewHandler.cacheRowHeights = false
tableViewHandler.updateRowAnimation = .none
tableViewHandler.moveRowAnimation = .none
tableViewHandler.insertRowAnimation = .none
tableViewHandler.disableAnimations = true
tableViewHandler.delegate = delegate
self.tableViewHandler = tableViewHandler
}

func resetResultsController() {
Expand Down

0 comments on commit b20381f

Please sign in to comment.