-
Notifications
You must be signed in to change notification settings - Fork 105
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
Conversation
Affected stories
New dependencies added: react-native-background-timerAuthor: David Ocetnik Description: Emit event periodically (even when app is in the background) Homepage: https://github.com/ocetnik/react-native-background-timer#readme
@types/react-native-background-timerAuthor: Unknown Description: TypeScript definitions for react-native-background-timer Homepage: http://npmjs.com/package/@types/react-native-background-timer
|
ts/IdentificationModal.tsx
Outdated
import { IdentificationState } from "./store/reducers/identification"; | ||
import { GlobalState } from "./store/reducers/types"; | ||
|
||
type MapStateToProps = { |
There was a problem hiding this comment.
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
ts/IdentificationModal.tsx
Outdated
import { GlobalState } from "./store/reducers/types"; | ||
|
||
type MapStateToProps = { | ||
identification: IdentificationState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identificationState
?
ts/IdentificationModal.tsx
Outdated
return null; | ||
}; | ||
|
||
class IdentificationModal extends React.PureComponent<Props, State> { |
There was a problem hiding this comment.
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
ts/IdentificationModal.tsx
Outdated
|
||
type Props = MapStateToProps & ReduxProps; | ||
|
||
type IdentificationByPinState = "unstarted" | "failure"; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
ts/IdentificationModal.tsx
Outdated
}; | ||
|
||
return ( | ||
<Modal |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seem related to microsoft/tslint-microsoft-contrib#329
@@ -19,9 +19,10 @@ const blurElement = (el: TextInput) => el.blur(); | |||
const current = (ref: React.RefObject<TextInput>) => ref.current; | |||
|
|||
interface Props { | |||
activeColor: string; | |||
clearOnInvalid?: boolean; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's right!
ts/sagas/identification.ts
Outdated
} | ||
|
||
// Identification was success return true | ||
return IdentificationResult.success; |
There was a problem hiding this comment.
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
fa8a06d
to
cf23a70
Compare
c9b17d1
to
9616734
Compare
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:
WIP: