Skip to content

Commit

Permalink
Code refactoring to implement suggestions from the code review.
Browse files Browse the repository at this point in the history
Binding the touchIdEnabled Buttons state directly to the userdefaults
value.

Fixed bug that disabled the TouchIdEnabled button on an unsucessfull
TouchId unlock
  • Loading branch information
Julius Zint committed Feb 21, 2021
1 parent 4aa8127 commit 3c54cd9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions MacPass/MPPasswordInputController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "MPTouchBarButtonCreator.h"
#import "MPSettingsHelper.h"
#import "MPConstants.h"
#import "MPSettingsHelper.h"

#import "HNHUi/HNHUi.h"

Expand Down Expand Up @@ -90,10 +91,11 @@ - (void)viewDidLoad {
[self.enablePasswordCheckBox bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(enablePassword)) options:nil];
[self.togglePasswordButton bind:NSEnabledBinding toObject:self withKeyPath:NSStringFromSelector(@selector(enablePassword)) options:nil];
[self.passwordTextField bind:NSEnabledBinding toObject:self withKeyPath:NSStringFromSelector(@selector(enablePassword)) options:nil];
NSUserDefaultsController *defaultsController = [NSUserDefaultsController sharedUserDefaultsController];
[self.touchIdEnabledButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEntryTouchIdEnabled] options:nil];
self.touchIdEnabledButton.hidden = true;
if (@available(macOS 10.13.4, *)) {
self.touchIdEnabledButton.hidden = false;
self.touchIdEnabledButton.state = [NSUserDefaults.standardUserDefaults integerForKey:kMPSettingsKeyEntryTouchIdEnabled];
[self _touchIdUpdateToolTip];
}
[self _reset];
Expand Down Expand Up @@ -371,12 +373,11 @@ - (IBAction)unlockWithTouchID:(id)sender {
if(success) {
return;
}
[self.touchIdEnabledButton setEnabled:false];
[self.touchIdButton setEnabled:false];
[self _showError:error];
}

- (IBAction)touchIdEnabledChanged:(id)sender {
[NSUserDefaults.standardUserDefaults setInteger: self.touchIdEnabledButton.state forKey:kMPSettingsKeyEntryTouchIdEnabled];
[self _touchIdUpdateToolTip];
}

Expand Down

0 comments on commit 3c54cd9

Please sign in to comment.