Registered to closeGrouping on undo manger to update searches on changes

This fixes issues with search not updating when something on the data model is changes e.g. via drag and drop. Also this fixes a display error that occured when an entry was dragged into the selected group in the outline view which would then show the group contents and not the search results
This commit is contained in:
Michael Starke
2019-03-04 18:12:30 +01:00
parent 1af690d485
commit e1b7b95f6b

View File

@@ -44,6 +44,7 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
self.searchContext = context;
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateSearch:) name:NSUndoManagerDidRedoChangeNotification object:self.undoManager];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateSearch:) name:NSUndoManagerDidUndoChangeNotification object:self.undoManager];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateSearch:) name:NSUndoManagerDidCloseUndoGroupNotification object:self.undoManager];
[NSNotificationCenter.defaultCenter postNotificationName:MPDocumentDidEnterSearchNotification object:self];
[self updateSearch:self];
}
@@ -58,7 +59,7 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
[self enterSearchWithContext:[MPEntrySearchContext userContext]];
return; // We get called back!
}
MPDocumentWindowController *windowController = [self windowControllers][0];
MPDocumentWindowController *windowController = self.windowControllers.firstObject;
self.searchContext.searchString = windowController.searchField.stringValue;
MPDocument __weak *weakSelf = self;
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
@@ -73,6 +74,7 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
- (void)exitSearch:(id)sender {
[NSNotificationCenter.defaultCenter removeObserver:self name:NSUndoManagerDidUndoChangeNotification object:self.undoManager];
[NSNotificationCenter.defaultCenter removeObserver:self name:NSUndoManagerDidRedoChangeNotification object:self.undoManager];
[NSNotificationCenter.defaultCenter removeObserver:self name:NSUndoManagerDidCloseUndoGroupNotification object:self.undoManager];
self.searchContext = nil;
[NSNotificationCenter.defaultCenter postNotificationName:MPDocumentDidExitSearchNotification object:self];
}
@@ -125,10 +127,6 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
}
}
- (NSArray *)entriesMatchingSearch:(MPEntrySearchContext *)search {
return nil;
}
#pragma mark Search
- (NSArray *)_findEntriesMatchingCurrentSearch {
/* Filter double passwords */