Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto close on success event behaviour and customization #370

Merged
merged 5 commits into from
Jan 17, 2017

Conversation

cocojoe
Copy link
Member

@cocojoe cocojoe commented Jan 12, 2017

Dismiss Lock on .Signup when .Login not present
Dismiss Lock on .ResetPassword when .Login not present
Added ForgetPassword event handling to Dispatcher
Added Dispatch/Dismiss tests to Database Password Interactor

@cocojoe
Copy link
Member Author

cocojoe commented Jan 12, 2017

I spoke to Victor regarding default behaviours and real life necessity of options, we both agreed on.

Current Behaviour:

  1. Login Success - Lock Closes Instantly
  2. Signup Success - Auto Login or Switches to .Login (if available) or nothing.
  3. Reset Success - Switches to .Login (If available) or nothing.
  4. Signup Screen (with no .Login, No Auto Login) - Nothing
  5. Reset Password Screen (with no .Login) - Nothing

PR Behaviour

  1. No Change
  2. No Change
  3. No Change
  4. Lock Closes
  5. Lock Closes

UPDATE:
Auto Close puts emphasis onto developer to use their own presentation solution so this removes any issues as per following comment. Therefore options are needed to opt-out of auto-close, if there is no auto-close we need to ensure/document that closeable is true.

@cocojoe
Copy link
Member Author

cocojoe commented Jan 12, 2017

One Ux issue is the lack of time to inform the user after a successful Signup / ResetPassword as the closure is instant.
This is currently the default behaviour for Login. It feels okay in this situation not to see a banner message. However for the other events, there is no means of confirmation.

resetpasswordclose

This is not in the PR but I tried adding a simple delay to event dismiss. Which I think looks okay, it's enough time to see it.

resetpassworddelay

@cocojoe
Copy link
Member Author

cocojoe commented Jan 13, 2017

Debated the consistently of disabling auto close on Login, started adding it then it seemed weird, even more so for other connection types. If really wanted it can be done of course, just doesn't feel right.

@cocojoe cocojoe changed the title Auto dismiss Lock on .Signup, .ResetPassword single screens Auto close on success event behaviour and customization Jan 13, 2017
@@ -35,6 +35,7 @@ public protocol Options {
var scope: String { get }
var parameters: [String: Any] { get }
var allow: DatabaseMode { get }
var autoClose: DatabaseMode { get }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a boolean I expect Lock to close on action?. This makes trickier figure out how to make lock close itself since I need to figure out what modes I want it to close. Also if I allow all actions and I set autoclose for signup I will close lock before the login? or for reset password ?

Copy link
Member Author

@cocojoe cocojoe Jan 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would certainly be simpler if it was just a flag, I was aiming for flexibility but agree sometimes we have too much and it can possibly be confusing. If we made this a Bool it would mean, only auto close .Signup or .Reset if there is no .Login.

In your scenario, by default all allow modes are set and all autoClose modes are set. Auto Close will only close .Signup or .ResetPassword if there is no .Login allowed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly should be autoCloseSingleScreens: Bool or a smaller name ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use autoclose and it's meant to close lock if the user logs in or any other action if it's the only one allowed. For consistency I'd avoid closing on auth if autoclose is false and show the same banner message we do for the rest.

@@ -28,24 +28,26 @@ struct ObserverStore: Dispatcher {
var onFailure: (Error) -> () = { _ in }
var onCancel: () -> () = { }
var onSignUp: (String, [String: Any]) -> () = { _ in }
var onForgetPassword: (String) -> () = { _ in }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be onForgotPassword?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, typo.


weak var controller: UIViewController?

func dispatch(result: Result) {
func dispatch(result: Result, dismissLock: Bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't by the extra parameter. This object should be able to decide for itself if it should dismiss or not using the options

@hzalaz hzalaz modified the milestone: v2-Next Jan 13, 2017
@cocojoe cocojoe force-pushed the feature_autoclose_signup_forgot branch from 23a8946 to 267103a Compare January 16, 2017 11:16
@cocojoe
Copy link
Member Author

cocojoe commented Jan 16, 2017

I'll squash these commits after review.

let connections: Connections
let emailValidator: InputValidator = EmailValidator()

init(connections: Connections, authentication: Authentication, user: DatabaseUser) {
init(connections: Connections, authentication: Authentication, user: DatabaseUser, options: Options, dispatcher: Dispatcher) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need Options for?


weak var controller: UIViewController?

init(options: Options = LockOptions()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to pass all the options?

@@ -28,24 +28,37 @@ struct ObserverStore: Dispatcher {
var onFailure: (Error) -> () = { _ in }
var onCancel: () -> () = { }
var onSignUp: (String, [String: Any]) -> () = { _ in }
var onForgotPassword: (String) -> () = { _ in }
var options: Options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have this mutable can't we just have the flag to tell lock to close itself after an action?

Copy link
Member Author

@cocojoe cocojoe Jan 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to know two things, Options.autoClose and are we in a single action mode. Currently determined with Options.allow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can either pass them independently of Options like 2 attributes or call a method to set them from Options. My main issue is passing it in the init since it provides no value let's just default to a sensible default and allow mutating the observerstore

func dispatch(result: Result) {
let dismissLock: Bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the need of this flag, we are making the decision of dismissing twice, one in the case and another after the switch. It's better to do it in the case and leave the closure to execute whether it has the dismiss or just calls the callback.

@@ -35,6 +35,7 @@ public protocol Options {
var scope: String { get }
var parameters: [String: Any] { get }
var allow: DatabaseMode { get }
var autoClose: DatabaseMode { get }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use autoclose and it's meant to close lock if the user logs in or any other action if it's the only one allowed. For consistency I'd avoid closing on auth if autoclose is false and show the same banner message we do for the rest.

Dismiss Lock on .ResetPassword when .Login not present
Added ForgetPassword event handling to Dispatcher
Added Dispatch/Dismiss tests to Database Password Interactor
Remove success banner display when auto closing
Added autoClose to options for specifying mode auto closing
Added validation for 'impossible to close Lock' miss configurations
Added more dispatch tests in DatabaseInteractor and DatabasePasswordInteractor
Login will always auto close for all connection types
Changed autoClose flag to Bool
Updated Tests
Removed Options from DatabasePasswordInteractor
Login now follows autoClose rules
Login success message added
DatabaseInteractor tests Added
Dispatcher related tests unified into ObserverStore tests
@cocojoe cocojoe force-pushed the feature_autoclose_signup_forgot branch from 267103a to 8c75bce Compare January 16, 2017 21:51
@hzalaz hzalaz merged commit 3b3631e into v2 Jan 17, 2017
@hzalaz hzalaz deleted the feature_autoclose_signup_forgot branch January 17, 2017 00:28
@hzalaz hzalaz modified the milestones: v2-Next, 2.0.0 Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants