From 2181898acdbffd5b82eb57943ad37a16fa1bac76 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Mon, 1 Nov 2021 23:47:53 +0100 Subject: [PATCH] Fixed missing updates when setting the time slice attribute --- MacPass/MPTOTPSetupViewController.m | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/MacPass/MPTOTPSetupViewController.m b/MacPass/MPTOTPSetupViewController.m index 143dffb4..9581b0b6 100644 --- a/MacPass/MPTOTPSetupViewController.m +++ b/MacPass/MPTOTPSetupViewController.m @@ -24,8 +24,6 @@ @property (nonatomic, readonly) KPKEntry *representedEntry; @property (copy) KPKTimeOTPGenerator *generator; -@property NSInteger timeSlice; - @end typedef NS_ENUM(NSUInteger, MPOTPUpdateSource) { @@ -75,6 +73,10 @@ typedef NS_ENUM(NSUInteger, MPOTPType) { [self _updateView:MPOTPUpdateSourceDigits]; } +- (IBAction)changeTimeSlice:(id)sender { + [self _updateView:MPOTPUpdateSourceTimeSlice]; +} + - (IBAction)parseQRCode:(id)sender { if(sender != self.qrCodeImageView) { return; // wrong sender @@ -101,6 +103,9 @@ typedef NS_ENUM(NSUInteger, MPOTPType) { else if(control == self.urlTextField) { [self _updateView:MPOTPUpdateSourceURL]; } + else if(control == self.timeStepTextField) { + [self _updateView:MPOTPUpdateSourceTimeSlice]; + } } - (void)_setupView { @@ -147,15 +152,18 @@ typedef NS_ENUM(NSUInteger, MPOTPType) { self.typePopUpButton.action = @selector(changeType:); self.typePopUpButton.target = self; + self.timeStepTextField.stringValue = @""; + self.timeStepStepper.integerValue = 0; - [self.timeStepTextField bind:NSValueBinding + self.timeStepStepper.action = @selector(changeTimeSlice:); + /*[self.timeStepTextField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(timeSlice)) options:nil]; [self.timeStepStepper bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(timeSlice)) - options:@{ NSConditionallySetsEnabledBindingOption:@(NO), NSConditionallySetsEditableBindingOption:@(NO)}]; + options:@{ NSConditionallySetsEnabledBindingOption:@(NO), NSConditionallySetsEditableBindingOption:@(NO)}];*/ self.secretTextField.delegate = self; self.urlTextField.delegate = self; @@ -234,7 +242,7 @@ typedef NS_ENUM(NSUInteger, MPOTPType) { self.generator.hashAlgorithm = (KPKOTPHashAlgorithm)self.algorithmPopUpButton.selectedTag; break; case MPOTPUpdateSourceTimeSlice: - self.generator.timeSlice = self.timeStepTextField.integerValue; + self.generator.timeSlice = self.timeStepStepper.integerValue; break; case MPOTPUpdateSourceDigits: self.generator.numberOfDigits = self.digitCountPopUpButton.selectedTag; @@ -299,7 +307,8 @@ typedef NS_ENUM(NSUInteger, MPOTPType) { self.secretTextField.stringValue = secret ? secret : @""; [self.algorithmPopUpButton selectItemWithTag:self.generator.hashAlgorithm]; [self.digitCountPopUpButton selectItemWithTag:self.generator.numberOfDigits]; - self.timeSlice = self.generator.timeSlice; + self.timeStepStepper.integerValue = self.generator.timeSlice; + self.timeStepTextField.stringValue = self.timeStepStepper.stringValue; } @end