Move a few batches of UI work into the main thread.
This commit is contained in:
parent
fa588f8fe2
commit
1977a423a5
@ -91,13 +91,15 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) {
|
|||||||
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
||||||
MPUserEntity *activeUser = [[MPiOSAppDelegate get] activeUserInContext:context];
|
MPUserEntity *activeUser = [[MPiOSAppDelegate get] activeUserInContext:context];
|
||||||
if (![MPAlgorithmDefault tryMigrateUser:activeUser inContext:context])
|
if (![MPAlgorithmDefault tryMigrateUser:activeUser inContext:context])
|
||||||
[self performSegueWithIdentifier:@"message" sender:
|
PearlMainQueue(^{
|
||||||
[MPMessage messageWithTitle:@"You have sites that can be upgraded." text:
|
[self performSegueWithIdentifier:@"message" sender:
|
||||||
@"Upgrading a site allows it to take advantage of the latest improvements in the Master Password algorithm.\n\n"
|
[MPMessage messageWithTitle:@"You have sites that can be upgraded." text:
|
||||||
"When you upgrade a site, a new and stronger password will be generated for it. To upgrade a site, first log into the site, navigate to your account preferences where you can change the site's password. Make sure you fill in any \"current password\" fields on the website first, then press the upgrade button here to get your new site password.\n\n"
|
@"Upgrading a site allows it to take advantage of the latest improvements in the Master Password algorithm.\n\n"
|
||||||
"You can then update your site's account with the new and stronger password.\n\n"
|
"When you upgrade a site, a new and stronger password will be generated for it. To upgrade a site, first log into the site, navigate to your account preferences where you can change the site's password. Make sure you fill in any \"current password\" fields on the website first, then press the upgrade button here to get your new site password.\n\n"
|
||||||
"The upgrade button can be found in the site's settings and looks like this:"
|
"You can then update your site's account with the new and stronger password.\n\n"
|
||||||
info:YES]];
|
"The upgrade button can be found in the site's settings and looks like this:"
|
||||||
|
info:YES]];
|
||||||
|
});
|
||||||
[context saveToStore];
|
[context saveToStore];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -417,36 +419,38 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) {
|
|||||||
if (![self.fetchedResultsController performFetch:&error])
|
if (![self.fetchedResultsController performFetch:&error])
|
||||||
err( @"Couldn't fetch sites: %@", [error fullDescription] );
|
err( @"Couldn't fetch sites: %@", [error fullDescription] );
|
||||||
|
|
||||||
@try {
|
PearlMainQueue(^{
|
||||||
[self.passwordCollectionView performBatchUpdates:^{
|
@try {
|
||||||
[self fetchedItemsDidUpdate];
|
[self.passwordCollectionView performBatchUpdates:^{
|
||||||
|
[self fetchedItemsDidUpdate];
|
||||||
NSInteger fromSections = self.passwordCollectionView.numberOfSections;
|
|
||||||
NSInteger toSections = [self numberOfSectionsInCollectionView:self.passwordCollectionView];
|
NSInteger fromSections = self.passwordCollectionView.numberOfSections;
|
||||||
for (NSInteger section = 0; section < MAX( toSections, fromSections ); ++section) {
|
NSInteger toSections = [self numberOfSectionsInCollectionView:self.passwordCollectionView];
|
||||||
if (section >= fromSections)
|
for (NSInteger section = 0; section < MAX( toSections, fromSections ); ++section) {
|
||||||
[self.passwordCollectionView insertSections:[NSIndexSet indexSetWithIndex:section]];
|
if (section >= fromSections)
|
||||||
else if (section >= toSections)
|
[self.passwordCollectionView insertSections:[NSIndexSet indexSetWithIndex:section]];
|
||||||
[self.passwordCollectionView deleteSections:[NSIndexSet indexSetWithIndex:section]];
|
else if (section >= toSections)
|
||||||
else if (section < [oldSections count])
|
[self.passwordCollectionView deleteSections:[NSIndexSet indexSetWithIndex:section]];
|
||||||
[self.passwordCollectionView reloadItemsFromArray:oldSections[section]
|
else if (section < [oldSections count])
|
||||||
toArray:[[self.fetchedResultsController sections][section] objects]
|
[self.passwordCollectionView reloadItemsFromArray:oldSections[section]
|
||||||
inSection:section];
|
toArray:[[self.fetchedResultsController sections][section] objects]
|
||||||
else
|
inSection:section];
|
||||||
[self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:section]];
|
else
|
||||||
}
|
[self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:section]];
|
||||||
} completion:^(BOOL finished) {
|
}
|
||||||
if (finished)
|
} completion:^(BOOL finished) {
|
||||||
[self.passwordCollectionView setContentOffset:CGPointMake( 0, -self.passwordCollectionView.contentInset.top )
|
if (finished)
|
||||||
animated:YES];
|
[self.passwordCollectionView setContentOffset:CGPointMake( 0, -self.passwordCollectionView.contentInset.top )
|
||||||
for (MPPasswordCell *cell in self.passwordCollectionView.visibleCells)
|
animated:YES];
|
||||||
[cell setFuzzyGroups:_fuzzyGroups];
|
for (MPPasswordCell *cell in self.passwordCollectionView.visibleCells)
|
||||||
}];
|
[cell setFuzzyGroups:_fuzzyGroups];
|
||||||
}
|
}];
|
||||||
@catch (NSException *exception) {
|
}
|
||||||
wrn( @"While updating password cells: %@", [exception fullDescription] );
|
@catch (NSException *exception) {
|
||||||
[self.passwordCollectionView reloadData];
|
wrn( @"While updating password cells: %@", [exception fullDescription] );
|
||||||
}
|
[self.passwordCollectionView reloadData];
|
||||||
|
}
|
||||||
|
});
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user