diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConnectionController.m | 58 | ||||
-rw-r--r-- | Source/SPFavoritesController.m | 2 |
2 files changed, 32 insertions, 28 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 979f59bb..f7a09471 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -1025,36 +1025,40 @@ static const NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist"; if ([contextInfo isEqualToString:SPRemoveNode]) { if (returnCode == NSAlertDefaultReturn) { - NSDictionary *favorite = [self selectedFavorite]; + SPTreeNode *node = [self selectedFavoriteNode]; - // Get selected favorite's details - NSString *favoriteName = [favorite objectForKey:SPFavoriteNameKey]; - NSString *favoriteUser = [favorite objectForKey:SPFavoriteUserKey]; - NSString *favoriteHost = [favorite objectForKey:SPFavoriteHostKey]; - NSString *favoriteDatabase = [favorite objectForKey:SPFavoriteDatabaseKey]; - NSString *favoriteSSHUser = [favorite objectForKey:SPFavoriteSSHUserKey]; - NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey]; - NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey]; - - NSInteger favoriteType = [[favorite objectForKey:SPFavoriteTypeKey] integerValue]; - - // Remove passwords from the Keychain - [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID] - account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]]; - [keychain deletePasswordForName:[keychain nameForSSHForFavoriteName:favoriteName id:favoriteID] - account:[keychain accountForSSHUser:favoriteSSHUser sshHost:favoriteSSHHost]]; - - // Reset last used favorite - if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPLastFavoriteID]) { - [prefs setInteger:0 forKey:SPLastFavoriteID]; - } - - // Reset default favorite - if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPDefaultFavorite]) { - [prefs setInteger:[prefs integerForKey:SPLastFavoriteID] forKey:SPDefaultFavorite]; + if (![node isGroup]) { + NSDictionary *favorite = [[node representedObject] nodeFavorite]; + + // Get selected favorite's details + NSString *favoriteName = [favorite objectForKey:SPFavoriteNameKey]; + NSString *favoriteUser = [favorite objectForKey:SPFavoriteUserKey]; + NSString *favoriteHost = [favorite objectForKey:SPFavoriteHostKey]; + NSString *favoriteDatabase = [favorite objectForKey:SPFavoriteDatabaseKey]; + NSString *favoriteSSHUser = [favorite objectForKey:SPFavoriteSSHUserKey]; + NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey]; + NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey]; + + NSInteger favoriteType = [[favorite objectForKey:SPFavoriteTypeKey] integerValue]; + + // Remove passwords from the Keychain + [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID] + account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]]; + [keychain deletePasswordForName:[keychain nameForSSHForFavoriteName:favoriteName id:favoriteID] + account:[keychain accountForSSHUser:favoriteSSHUser sshHost:favoriteSSHHost]]; + + // Reset last used favorite + if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPLastFavoriteID]) { + [prefs setInteger:0 forKey:SPLastFavoriteID]; + } + + // Reset default favorite + if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPDefaultFavorite]) { + [prefs setInteger:[prefs integerForKey:SPLastFavoriteID] forKey:SPDefaultFavorite]; + } } - [favoritesController removeFavoriteNode:[self selectedFavoriteNode]]; + [favoritesController removeFavoriteNode:node]; [self _reloadFavoritesViewData]; diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m index 2d711c4b..920cec6b 100644 --- a/Source/SPFavoritesController.m +++ b/Source/SPFavoritesController.m @@ -174,7 +174,7 @@ static SPFavoritesController *sharedFavoritesController = nil; [favoritesTree removeObjectFromChildren:node]; // Save data to disk - [self saveFavorites]; + [self reloadFavoritesWithSave:YES]; } #pragma mark - |