Don't forget the active user when signing out, so sign-in can re-use the same user.
Also fix some deprecated method usages.
This commit is contained in:
parent
b9298996e8
commit
3a70d5e38d
@ -100,7 +100,6 @@ static NSDictionary *createKeyQuery(MPUserEntity *user, BOOL newItem, MPKeyOrigi
|
|||||||
if (self.key)
|
if (self.key)
|
||||||
self.key = nil;
|
self.key = nil;
|
||||||
|
|
||||||
self.activeUser = nil;
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPSignedOutNotification object:self userInfo:@{ @"animated" : @(animated) }];
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPSignedOutNotification object:self userInfo:@{ @"animated" : @(animated) }];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,11 +259,8 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
NSURL *url = openPanel.URL;
|
NSURL *url = openPanel.URL;
|
||||||
[openPanel close];
|
[openPanel close];
|
||||||
|
|
||||||
PearlNotMainQueue( ^{
|
[[NSURLSession sharedSession]
|
||||||
NSError *error;
|
dataTaskWithURL:url completionHandler:^(NSData *importedSitesData, NSURLResponse *response, NSError *error) {
|
||||||
NSURLResponse *response;
|
|
||||||
NSData *importedSitesData = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:url]
|
|
||||||
returningResponse:&response error:&error];
|
|
||||||
if (error)
|
if (error)
|
||||||
err( @"While reading imported sites from %@: %@", url, [error fullDescription] );
|
err( @"While reading imported sites from %@: %@", url, [error fullDescription] );
|
||||||
if (!importedSitesData)
|
if (!importedSitesData)
|
||||||
@ -335,7 +332,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
} );
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)togglePreference:(id)sender {
|
- (IBAction)togglePreference:(id)sender {
|
||||||
@ -367,16 +364,18 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
|
|
||||||
- (IBAction)newUser:(NSMenuItem *)sender {
|
- (IBAction)newUser:(NSMenuItem *)sender {
|
||||||
|
|
||||||
NSAlert *alert = [NSAlert alertWithMessageText:@"New User"
|
NSAlert *alert = [NSAlert new];
|
||||||
defaultButton:@"Create User" alternateButton:nil otherButton:@"Cancel"
|
[alert setMessageText:@"New User"];
|
||||||
informativeTextWithFormat:@"To begin, enter your full name.\n\n"
|
[alert setInformativeText:@"To begin, enter your full name.\n\n"
|
||||||
@"IMPORTANT: Enter your name correctly, including the right capitalization, "
|
@"IMPORTANT: Enter your name correctly, including the right capitalization, "
|
||||||
@"as you would on an official document."];
|
@"as you would on an official document."];
|
||||||
|
[alert addButtonWithTitle:@"Create User"];
|
||||||
|
[alert addButtonWithTitle:@"Cancel"];
|
||||||
NSTextField *nameField = [[NSTextField alloc] initWithFrame:NSMakeRect( 0, 0, 200, 22 )];
|
NSTextField *nameField = [[NSTextField alloc] initWithFrame:NSMakeRect( 0, 0, 200, 22 )];
|
||||||
[alert setAccessoryView:nameField];
|
[alert setAccessoryView:nameField];
|
||||||
[alert layout];
|
[alert layout];
|
||||||
[nameField becomeFirstResponder];
|
[nameField becomeFirstResponder];
|
||||||
if ([alert runModal] != NSAlertDefaultReturn)
|
if ([alert runModal] != NSAlertFirstButtonReturn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NSString *name = [(NSSecureTextField *)alert.accessoryView stringValue];
|
NSString *name = [(NSSecureTextField *)alert.accessoryView stringValue];
|
||||||
@ -399,10 +398,12 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
|
|
||||||
- (IBAction)deleteUser:(NSMenuItem *)sender {
|
- (IBAction)deleteUser:(NSMenuItem *)sender {
|
||||||
|
|
||||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Delete User"
|
NSAlert *alert = [NSAlert new];
|
||||||
defaultButton:@"Delete" alternateButton:nil otherButton:@"Cancel"
|
[alert setMessageText:@"Delete User"];
|
||||||
informativeTextWithFormat:@"This will delete %@ and all their sites.", self.activeUserForMainThread.name];
|
[alert setInformativeText:strf( @"This will delete %@ and all their sites.", self.activeUserForMainThread.name )];
|
||||||
if ([alert runModal] != NSAlertDefaultReturn)
|
[alert addButtonWithTitle:@"Delete"];
|
||||||
|
[alert addButtonWithTitle:@"Cancel"];
|
||||||
|
if ([alert runModal] != NSAlertFirstButtonReturn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *moc) {
|
[MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *moc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user