Add possible fixes for the ‘empty home view’ issue.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 3f805cd4cd
commit f52814bb70

@ -415,7 +415,15 @@
- (void)setShouldObserveDBModifications:(BOOL)shouldObserveDBModifications - (void)setShouldObserveDBModifications:(BOOL)shouldObserveDBModifications
{ {
if (!_shouldObserveDBModifications && shouldObserveDBModifications && self.threadMappings != nil) { _shouldObserveDBModifications = shouldObserveDBModifications;
[self ensureObserveDBModifications];
}
- (void)ensureObserveDBModifications
{
if (self.shouldObserveDBModifications) {
if (self.threadMappings != nil) {
// Before we begin observing database modifications, make sure // Before we begin observing database modifications, make sure
// our mapping and table state is up-to-date. // our mapping and table state is up-to-date.
// //
@ -425,19 +433,17 @@
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[self.threadMappings updateWithTransaction:transaction]; [self.threadMappings updateWithTransaction:transaction];
}]; }];
}
[[self tableView] reloadData]; [[self tableView] reloadData];
} }
_shouldObserveDBModifications = shouldObserveDBModifications; [[NSNotificationCenter defaultCenter] removeObserver:self name:YapDatabaseModifiedNotification object:nil];
if (self.shouldObserveDBModifications) {
if (shouldObserveDBModifications) {
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:) selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification name:YapDatabaseModifiedNotification
object:nil]; object:nil];
} else {
[[NSNotificationCenter defaultCenter] removeObserver:self name:YapDatabaseModifiedNotification object:nil];
} }
[self checkIfEmptyView]; [self checkIfEmptyView];

Loading…
Cancel
Save