From e1b7b95f6b76a55ada80e524157ae0cc2119c115 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Mon, 4 Mar 2019 18:12:30 +0100 Subject: [PATCH] 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 --- MacPass/MPDocument+Search.m | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/MacPass/MPDocument+Search.m b/MacPass/MPDocument+Search.m index 79ceed8e..af22e3f2 100644 --- a/MacPass/MPDocument+Search.m +++ b/MacPass/MPDocument+Search.m @@ -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 */