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: Fix broken table reload animations #23807

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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