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

[#161224146] Refactor light identification #658

Merged
merged 7 commits into from
Oct 16, 2018
Merged

Conversation

fpersico
Copy link
Contributor

@fpersico fpersico commented Oct 15, 2018

In the PR:

A IdentificationModal that allow the user to do a light identification. The modal is rendered by the RootContainer and outside the navigation. For the moment the identification is only by PIN. When going in background the identification is started by the react-native-background-timer module so we don't need the BackgroundScreen anymore.

The identification process can be started:

  • Calling a saga method directly and synchronously waiting for the identification result: this method is used by the startup saga
  • Dispatching and action: in this case you can pass Actions that the internal process will dispatch on success and cancel.

WIP:

  • Test if background-timer fire on iOS.
  • Attach the new identification to the payment process (already done locally, need to review the code after the latest payment refactor)
  • Remove old unused code/files

@fpersico fpersico requested a review from cloudify October 15, 2018 08:55
@digitalcitizenship
Copy link

digitalcitizenship commented Oct 15, 2018

Affected stories

  • 🌟 #161224146: Light identification refactoring

New dependencies added: react-native-background-timer and @types/react-native-background-timer.

react-native-background-timer

Author: David Ocetnik

Description: Emit event periodically (even when app is in the background)

Homepage: https://github.com/ocetnik/react-native-background-timer#readme

Createdover 2 years ago
Last Updatedabout 2 months ago
LicenseMIT
Maintainers1
Releases23
Keywordsandroid, ios, react-component, react-native and timer

@types/react-native-background-timer

Author: Unknown

Description: TypeScript definitions for react-native-background-timer

Homepage: http://npmjs.com/package/@types/react-native-background-timer

Created4 months ago
Last Updated6 days ago
LicenseMIT
Maintainers1
Releases1
Direct Dependencies
README

Installation

npm install --save @types/react-native-background-timer

Summary

This package contains type definitions for react-native-background-timer (https://github.com/ocetnik/react-native-background-timer#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-native-background-timer

Additional Details

  • Last updated: Tue, 26 Jun 2018 01:10:51 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Tjark Smalla https://github.com/chillkroeteTTS.

Generated by 🚫 dangerJS

import { IdentificationState } from "./store/reducers/identification";
import { GlobalState } from "./store/reducers/types";

type MapStateToProps = {
Copy link
Contributor

Choose a reason for hiding this comment

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

we call this ReduxMappedStateProps in the rest of the codebase

import { GlobalState } from "./store/reducers/types";

type MapStateToProps = {
identification: IdentificationState;
Copy link
Contributor

Choose a reason for hiding this comment

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

identificationState ?

return null;
};

class IdentificationModal extends React.PureComponent<Props, State> {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment describing the purpose of this component


type Props = MapStateToProps & ReduxProps;

type IdentificationByPinState = "unstarted" | "failure";
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the difference between IdentificationState and IdentificationByPinState, could you add some comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes going to add comments. For the moment we have only PIN identification but in future we'll have also other identification methods (like fingerprint). IdentificationState is to store the global user identification. IdentificationByPinState is a local state to check the result of the matching in Pinpad component.

};

return (
<Modal
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need a modal? can't this be just a screen rendered on top of everything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A screen? You mean a react-navigation screen or something else? The purpose is to leave the AppNavigator untouched and just display something that force the user to identify.

Copy link
Contributor

@cloudify cloudify Oct 15, 2018

Choose a reason for hiding this comment

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

I mean something simple like ConnectionBar or VersionInfoOverlay

// the app we don't ask a PIN
yield put(navigateToBackgroundScreen);
// Start the background timer
identificationBackgroundTimer = yield fork(
Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't look like startIdentificationBackgroundTimer returns anything

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The return of "fork" effect is a redux-saga Task you can cancel.

});
}

function* startIdentificationBackgroundTimer(
Copy link
Contributor

Choose a reason for hiding this comment

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

this function is only two instructions and it's only called once, why not inline it?

import BackgroundTimer from "react-native-background-timer";

export function startTimer(t: number): Promise<never> {
// tslint:disable-next-line:promise-must-complete
Copy link
Contributor

Choose a reason for hiding this comment

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

why tslint was complaining here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -19,9 +19,10 @@ const blurElement = (el: TextInput) => el.blur();
const current = (ref: React.RefObject<TextInput>) => ref.current;

interface Props {
activeColor: string;
clearOnInvalid?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems that now PinPad is used only in one place and clearOnInvalid is set to true, why we need it to be configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to check but isn't the Pinpad also used during the Onboarding?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's right!

}

// Identification was success return true
return IdentificationResult.success;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not default to success here, wrap it with an if as well

@fpersico fpersico force-pushed the light-identification branch from fa8a06d to cf23a70 Compare October 15, 2018 14:44
@fpersico fpersico changed the title [WIP] Refactor light identification [#161224146] Refactor light identification Oct 15, 2018
@fpersico fpersico force-pushed the light-identification branch from c9b17d1 to 9616734 Compare October 15, 2018 16:21
@fpersico fpersico merged commit 369221e into master Oct 16, 2018
@fabriziofff fabriziofff deleted the light-identification branch January 21, 2022 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants