From 3a70d5e38d8ffdac668b093ca6ad2286d53ae7ef Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sat, 2 Jul 2016 09:04:31 -0400 Subject: [PATCH] Don't forget the active user when signing out, so sign-in can re-use the same user. Also fix some deprecated method usages. --- MasterPassword/ObjC/MPAppDelegate_Key.m | 1 - MasterPassword/ObjC/Mac/MPMacAppDelegate.m | 33 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/MasterPassword/ObjC/MPAppDelegate_Key.m b/MasterPassword/ObjC/MPAppDelegate_Key.m index 4c055070..79b08327 100644 --- a/MasterPassword/ObjC/MPAppDelegate_Key.m +++ b/MasterPassword/ObjC/MPAppDelegate_Key.m @@ -100,7 +100,6 @@ static NSDictionary *createKeyQuery(MPUserEntity *user, BOOL newItem, MPKeyOrigi if (self.key) self.key = nil; - self.activeUser = nil; [[NSNotificationCenter defaultCenter] postNotificationName:MPSignedOutNotification object:self userInfo:@{ @"animated" : @(animated) }]; } diff --git a/MasterPassword/ObjC/Mac/MPMacAppDelegate.m b/MasterPassword/ObjC/Mac/MPMacAppDelegate.m index b06a27c5..d0a2d2b1 100644 --- a/MasterPassword/ObjC/Mac/MPMacAppDelegate.m +++ b/MasterPassword/ObjC/Mac/MPMacAppDelegate.m @@ -259,11 +259,8 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven NSURL *url = openPanel.URL; [openPanel close]; - PearlNotMainQueue( ^{ - NSError *error; - NSURLResponse *response; - NSData *importedSitesData = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:url] - returningResponse:&response error:&error]; + [[NSURLSession sharedSession] + dataTaskWithURL:url completionHandler:^(NSData *importedSitesData, NSURLResponse *response, NSError *error) { if (error) err( @"While reading imported sites from %@: %@", url, [error fullDescription] ); if (!importedSitesData) @@ -335,7 +332,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven break; } } ); - } ); + }]; } - (IBAction)togglePreference:(id)sender { @@ -367,16 +364,18 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven - (IBAction)newUser:(NSMenuItem *)sender { - NSAlert *alert = [NSAlert alertWithMessageText:@"New User" - defaultButton:@"Create User" alternateButton:nil otherButton:@"Cancel" - informativeTextWithFormat:@"To begin, enter your full name.\n\n" - @"IMPORTANT: Enter your name correctly, including the right capitalization, " - @"as you would on an official document."]; + NSAlert *alert = [NSAlert new]; + [alert setMessageText:@"New User"]; + [alert setInformativeText:@"To begin, enter your full name.\n\n" + @"IMPORTANT: Enter your name correctly, including the right capitalization, " + @"as you would on an official document."]; + [alert addButtonWithTitle:@"Create User"]; + [alert addButtonWithTitle:@"Cancel"]; NSTextField *nameField = [[NSTextField alloc] initWithFrame:NSMakeRect( 0, 0, 200, 22 )]; [alert setAccessoryView:nameField]; [alert layout]; [nameField becomeFirstResponder]; - if ([alert runModal] != NSAlertDefaultReturn) + if ([alert runModal] != NSAlertFirstButtonReturn) return; NSString *name = [(NSSecureTextField *)alert.accessoryView stringValue]; @@ -399,10 +398,12 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven - (IBAction)deleteUser:(NSMenuItem *)sender { - NSAlert *alert = [NSAlert alertWithMessageText:@"Delete User" - defaultButton:@"Delete" alternateButton:nil otherButton:@"Cancel" - informativeTextWithFormat:@"This will delete %@ and all their sites.", self.activeUserForMainThread.name]; - if ([alert runModal] != NSAlertDefaultReturn) + NSAlert *alert = [NSAlert new]; + [alert setMessageText:@"Delete User"]; + [alert setInformativeText:strf( @"This will delete %@ and all their sites.", self.activeUserForMainThread.name )]; + [alert addButtonWithTitle:@"Delete"]; + [alert addButtonWithTitle:@"Cancel"]; + if ([alert runModal] != NSAlertFirstButtonReturn) return; [MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *moc) {