2
0

Honour animated property better.

Also: don't need to force a layout if not in an animation block.
This commit is contained in:
Maarten Billemont 2020-04-12 19:13:34 -04:00
parent f80ffd078b
commit b428ee0003

View File

@ -512,16 +512,24 @@
- (void)updateAnimated:(BOOL)animated { - (void)updateAnimated:(BOOL)animated {
Weakify( self );
if (![NSThread isMainThread]) { if (![NSThread isMainThread]) {
PearlMainQueueOperation( ^{ PearlMainQueueOperation( ^{
Strongify( self );
[self updateAnimated:animated]; [self updateAnimated:animated];
} ); } );
return; return;
} }
[UIView animateWithDuration:animated? .3f: 0 animations:^{ if (animated)
[UIView animateWithDuration:.3f animations:^{
[self updateWasAnimated:animated];
}];
else
[self updateWasAnimated:animated];
}
- (void)updateWasAnimated:(BOOL)animated {
Weakify( self );
MPSiteEntity *mainSite = [self siteInContext:[MPiOSAppDelegate managedObjectContextForMainThreadIfReady]]; MPSiteEntity *mainSite = [self siteInContext:[MPiOSAppDelegate managedObjectContextForMainThreadIfReady]];
// UI // UI
@ -572,7 +580,7 @@
wrn( @"Could not load cell content: key unavailable." ); wrn( @"Could not load cell content: key unavailable." );
PearlMainQueueOperation( ^{ PearlMainQueueOperation( ^{
Strongify( self ); Strongify( self );
[self updateAnimated:YES]; [self updateAnimated:animated];
} ); } );
return; return;
} }
@ -632,12 +640,12 @@
wrn( @"Could not load cell content: store unavailable." ); wrn( @"Could not load cell content: store unavailable." );
PearlMainQueueOperation( ^{ PearlMainQueueOperation( ^{
Strongify( self ); Strongify( self );
[self updateAnimated:YES]; [self updateAnimated:animated];
} ); } );
} }
if (animated)
[self.contentView layoutIfNeeded]; [self.contentView layoutIfNeeded];
}];
} }
- (void)updateSiteName:(MPSiteEntity *)site { - (void)updateSiteName:(MPSiteEntity *)site {