Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

Fix for Tapping "I want this", then cancelling does not bring back th… #374

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/UVBaseViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
// specialized behavior.
- (void)didReceiveError:(NSError *)error;

- (void)requireUserSignedIn:(UVCallback *)callback;
- (void)requireUserSignedIn:(UVCallback *)callback ifCanceledDo:(UVCallback *)cancelCallBack;
- (void)requireUserAuthenticated:(NSString *)email name:(NSString *)name callback:(UVCallback *)callback;

// Keyboard handling
Expand Down
5 changes: 2 additions & 3 deletions Classes/UVBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,9 @@ - (void)setView:(UIView *)view {
}
}

- (void)requireUserSignedIn:(UVCallback *)callback {
[_signinManager signInWithCallback:callback];
- (void)requireUserSignedIn:(UVCallback *)callback ifCanceledDo:(UVCallback *)cancelCallBack {
[_signinManager signInWithCallback:callback cancelCallBack:cancelCallBack];
}

- (void)requireUserAuthenticated:(NSString *)email name:(NSString *)name callback:(UVCallback *)callback {
[_signinManager signInWithEmail:email name:name callback:callback];
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/UVSigninManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

+ (UVSigninManager *)manager;

- (void)signInWithCallback:(UVCallback *)callback;
- (void)signInWithCallback:(UVCallback *)callback cancelCallBack:(UVCallback *)cancelCallBack;
- (void)signInWithEmail:(NSString *)theEmail name:(NSString *)theName callback:(UVCallback *)callback;

@property (nonatomic, assign) id<UVSigninManagerDelegate> delegate;
Expand Down
19 changes: 15 additions & 4 deletions Classes/UVSigninManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@implementation UVSigninManager {
NSInteger _state;
UVCallback *_callback;
UVCallback *_cancelCallback;
NSRegularExpression *_emailFormat;
}

Expand Down Expand Up @@ -112,7 +113,7 @@ - (void)showEmailFormatError {
[self invokeDidFail];
}

- (void)signInWithCallback:(UVCallback *)callback {
- (void)signInWithCallback:(UVCallback *)callback cancelCallBack:(UVCallback *)cancelCallBack; {
if ([self user]) {
[callback invokeCallback:nil];
} else {
Expand All @@ -123,6 +124,7 @@ - (void)signInWithCallback:(UVCallback *)callback {
[self signInWithEmail:storedEmail name:storedName callback:callback];
} else {
_callback = callback;
_cancelCallback = cancelCallBack;
[self showEmailAlertView];
}
}
Expand Down Expand Up @@ -204,11 +206,20 @@ - (void)didSendForgotPassword:(id)obj {

- (void)alertView:(UIAlertView *)theAlertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
if (_state == STATE_EMAIL) {
if (buttonIndex == 1) {
if (buttonIndex == 0) {
if (_cancelCallback) {
[_cancelCallback invokeCallback:nil];
_cancelCallback = nil;
}
}else if(buttonIndex == 1) {
NSString *text = [_alertView textFieldAtIndex:0].text;
if (text.length == 0)
if (text.length == 0){
if (_cancelCallback) {
[_cancelCallback invokeCallback:nil];
_cancelCallback = nil;
}
return;

}
_email = text;
[UVUser discoverWithEmail:text delegate:self];
}
Expand Down
8 changes: 7 additions & 1 deletion Classes/UVSuggestionDetailsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ @implementation UVSuggestionDetailsViewController {
BOOL _subscribing;
BOOL _loading;
UVCallback *_subscribeCallback;
UVCallback *_canceledEmailInputOnsubscribeCallback;
UISwitch *_toggle;
}

Expand All @@ -49,6 +50,7 @@ - (id)init {

if (self) {
_subscribeCallback = [[UVCallback alloc] initWithTarget:self selector:@selector(doSubscribe)];
_canceledEmailInputOnsubscribeCallback = [[UVCallback alloc] initWithTarget:self selector:@selector(cancelledEmailInputSubscribe)];
}

return self;
Expand Down Expand Up @@ -393,7 +395,11 @@ - (void)toggleSubscribed {
- (void)subscribe {
if (_subscribing) return;
_subscribing = YES;
[self requireUserSignedIn:_subscribeCallback];
[self requireUserSignedIn:_subscribeCallback ifCanceledDo:_canceledEmailInputOnsubscribeCallback];
}

- (void)cancelledEmailInputSubscribe{
_subscribing = NO;
}

- (void)doSubscribe {
Expand Down