2
0

Fixed updating search results when query is no match or element deleted.

[FIXED]     Make search results empty when no results.
[FIXED]     Update search results upon deletion.
This commit is contained in:
Maarten Billemont 2014-02-28 20:44:29 -05:00
parent 658d710847
commit 4184f609d6
7 changed files with 46 additions and 26 deletions

View File

@ -7,7 +7,7 @@
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>Crashlytics</string> <string>Crashlytics</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.crashlytics.ios</string> <string>com.crashlytics.sdk.mac</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
@ -15,16 +15,16 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.1.6</string> <string>2.1.2</string>
<key>CFBundleSupportedPlatforms</key> <key>CFBundleSupportedPlatforms</key>
<array> <array>
<string>iPhoneOS</string> <string>macosx</string>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>21</string> <string>9</string>
<key>DTPlatformName</key> <key>DTPlatformName</key>
<string>iphoneos</string> <string>macosx</string>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>4.0</string> <string>10.6</string>
</dict> </dict>
</plist> </plist>

View File

@ -205,6 +205,8 @@
MPElementEntity *element = [self.representedObject entityInContext:context]; MPElementEntity *element = [self.representedObject entityInContext:context];
[context deleteObject:element]; [context deleteObject:element];
[context saveToStore]; [context saveToStore];
[((MPPasswordWindowController *)self.collectionView.window.windowController) updateElements];
}]; }];
break; break;
} }

View File

@ -18,4 +18,6 @@
@property(nonatomic, weak) IBOutlet NSTextField *userLabel; @property(nonatomic, weak) IBOutlet NSTextField *userLabel;
@property(nonatomic, weak) IBOutlet NSCollectionView *siteCollectionView; @property(nonatomic, weak) IBOutlet NSCollectionView *siteCollectionView;
- (void)updateElements;
@end @end

View File

@ -178,14 +178,17 @@
} }
if (contextInfo == MPAlertCreateSite) { if (contextInfo == MPAlertCreateSite) {
switch (returnCode) { switch (returnCode) {
case NSAlertDefaultReturn: { case NSAlertFirstButtonReturn: {
// "Create" button.
[[MPMacAppDelegate get] addElementNamed:[self.siteField stringValue] completion:^(MPElementEntity *element) { [[MPMacAppDelegate get] addElementNamed:[self.siteField stringValue] completion:^(MPElementEntity *element) {
if (element) { if (element)
[self updateElements]; [self updateElements];
}
}]; }];
break; break;
} }
case NSAlertThirdButtonReturn:
// "Cancel" button.
break;
default: default:
break; break;
} }
@ -345,23 +348,35 @@
NSError *error = nil; NSError *error = nil;
NSArray *siteResults = [context executeFetchRequest:fetchRequest error:&error]; NSArray *siteResults = [context executeFetchRequest:fetchRequest error:&error];
if (!siteResults) if (!siteResults) {
err(@"While fetching elements for completion: %@", error); err(@"While fetching elements for completion: %@", error);
else if ([siteResults count]) { return;
NSMutableArray *newElements = [NSMutableArray arrayWithCapacity:[siteResults count]];
for (MPElementEntity *element in siteResults)
[newElements addObject:[[MPElementModel alloc] initWithEntity:element]];
self.elements = newElements;
if (!self.selectedElement && [newElements count])
self.elementSelectionIndexes = [NSIndexSet indexSetWithIndex:0];
} }
NSMutableArray *newElements = [NSMutableArray arrayWithCapacity:[siteResults count]];
for (MPElementEntity *element in siteResults)
[newElements addObject:[[MPElementModel alloc] initWithEntity:element]];
self.elements = newElements;
if (!self.selectedElement)
self.elementSelectionIndexes = [newElements count]? [NSIndexSet indexSetWithIndex:0]: nil;
}]; }];
} }
- (NSUInteger)selectedIndex {
if (!self.elementSelectionIndexes)
return NSNotFound;
NSUInteger selectedIndex = self.elementSelectionIndexes.firstIndex;
if (selectedIndex >= self.elements.count)
return NSNotFound;
return selectedIndex;
}
- (NSBox *)selectedView { - (NSBox *)selectedView {
NSUInteger selectedIndex = self.elementSelectionIndexes.firstIndex; NSUInteger selectedIndex = [self selectedIndex];
if (selectedIndex == NSNotFound || selectedIndex >= self.elements.count) if (selectedIndex == NSNotFound)
return nil; return nil;
return (NSBox *)[self.siteCollectionView itemAtIndex:selectedIndex].view; return (NSBox *)[self.siteCollectionView itemAtIndex:selectedIndex].view;
@ -369,10 +384,11 @@
- (MPElementModel *)selectedElement { - (MPElementModel *)selectedElement {
if (!self.elementSelectionIndexes.count) NSUInteger selectedIndex = [self selectedIndex];
if (selectedIndex == NSNotFound)
return nil; return nil;
return (MPElementModel *)self.elements[self.elementSelectionIndexes.firstIndex]; return (MPElementModel *)self.elements[selectedIndex];
} }
- (void)setSelectedElement:(MPElementModel *)element { - (void)setSelectedElement:(MPElementModel *)element {

View File

@ -1978,7 +1978,7 @@
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = MasterPassword.entitlements; CODE_SIGN_ENTITLEMENTS = MasterPassword.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer: Maarten Billemont (DWGU95U4ZD)";
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
GCC_PREFIX_HEADER = "MasterPassword-Prefix.pch"; GCC_PREFIX_HEADER = "MasterPassword-Prefix.pch";
INFOPLIST_FILE = "MasterPassword-Info.plist"; INFOPLIST_FILE = "MasterPassword-Info.plist";

View File

@ -4,11 +4,11 @@
<dict> <dict>
<key>com.apple.developer.ubiquity-container-identifiers</key> <key>com.apple.developer.ubiquity-container-identifiers</key>
<array> <array>
<string>$(TeamIdentifierPrefix)com.lyndir.lhunath.MasterPassword.Mac</string> <string>HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.Mac</string>
<string>$(TeamIdentifierPrefix)com.lyndir.lhunath.MasterPassword.shared</string> <string>HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.shared</string>
</array> </array>
<key>com.apple.developer.ubiquity-kvstore-identifier</key> <key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)com.lyndir.lhunath.MasterPassword.shared</string> <string>HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.shared</string>
<key>com.apple.security.app-sandbox</key> <key>com.apple.security.app-sandbox</key>
<true/> <true/>
</dict> </dict>