Skip to content

Commit

Permalink
Merge branch 'master' into 174859517-cta-check-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisTofani authored Sep 25, 2020
2 parents bd788af + 63b08ff commit b7d1a46
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 64 deletions.
5 changes: 1 addition & 4 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ profile:
alert: Are you sure you want to clear the cache?
clear: Clear cache
cleared: The cache has been cleared.
resetPin:
confirmTitle: Are you sure you want to reset your unlock code?
confirmMsg: You will be asked again to log in.
preferences:
title: Preferences
description: Manage app internal preferences
Expand Down Expand Up @@ -1542,4 +1539,4 @@ webView:
error:
missingParams: Not all information necessary to access this page are available
missingToken: Missing authorization to start this flow
convertMessage: Unable to decode the message from the webview
convertMessage: Unable to decode the message from the webview
3 changes: 0 additions & 3 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ profile:
alert: Vuoi davvero eliminare la cache?
clear: Elimina cache
cleared: La cache è stata eliminata.
resetPin:
confirmTitle: Vuoi davvero reimpostare il codice di sblocco?
confirmMsg: Ti verrà richiesto nuovamente di accedere.
preferences:
title: Preferenze
description: Gestisci le preferenze dell'applicazione
Expand Down
16 changes: 12 additions & 4 deletions ts/sagas/identification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import {
identificationStart,
identificationSuccess
} from "../store/actions/identification";
import { navigateToMessageDetailScreenAction } from "../store/actions/navigation";
import {
navigateToMessageDetailScreenAction,
navigateToOnboardingPinScreenAction
} from "../store/actions/navigation";
import { clearNotificationPendingMessage } from "../store/actions/notifications";
import {
paymentDeletePayment,
Expand All @@ -40,6 +43,7 @@ import { isPaymentOngoingSelector } from "../store/reducers/wallet/payment";
import { PinString } from "../types/PinString";
import { SagaCallReturnType } from "../types/utils";
import { deletePin } from "../utils/keychain";
import { updatePin } from "../store/actions/pinset";

type ResultAction =
| ActionType<typeof identificationCancel>
Expand Down Expand Up @@ -180,12 +184,16 @@ function* startAndHandleIdentificationResult(
}
}

export function* watchIdentificationRequest(
pin: PinString
): IterableIterator<Effect> {
export function* watchIdentification(pin: PinString): IterableIterator<Effect> {
// Watch for identification request
yield takeLatest(
getType(identificationRequest),
startAndHandleIdentificationResult,
pin
);

// Watch for requests to update the unlock code.
yield takeLatest(getType(updatePin), function* () {
yield put(navigateToOnboardingPinScreenAction);
});
}
9 changes: 3 additions & 6 deletions ts/sagas/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { startTimer } from "../utils/timer";
import { watchBonusBpdSaga } from "../features/bonus/bpd/saga";
import {
startAndReturnIdentificationResult,
watchIdentificationRequest
watchIdentification
} from "./identification";
import { previousInstallationDataDeleteSaga } from "./installation";
import { updateInstallationSaga } from "./notifications";
Expand All @@ -82,7 +82,6 @@ import { watchMessagesLoadOrCancelSaga } from "./startup/watchLoadMessagesSaga";
import { loadMessageWithRelationsSaga } from "./startup/watchLoadMessageWithRelationsSaga";
import { watchLogoutSaga } from "./startup/watchLogoutSaga";
import { watchMessageLoadSaga } from "./startup/watchMessageLoadSaga";
import { watchPinResetSaga } from "./startup/watchPinResetSaga";
import { watchSessionExpiredSaga } from "./startup/watchSessionExpiredSaga";
import { watchUserDataProcessingSaga } from "./user/userDataProcessing";
import {
Expand Down Expand Up @@ -358,10 +357,8 @@ export function* initializeApplicationSaga(): Generator<Effect, void, any> {

// Watch for requests to logout
yield spawn(watchLogoutSaga, backendClient.logout);
// Watch for requests to reset the unlock code.
yield fork(watchPinResetSaga);
// Watch for identification request
yield fork(watchIdentificationRequest, storedPin);

yield fork(watchIdentification, storedPin);

// Watch for checking the user email notifications preferences
yield fork(watchEmailNotificationPreferencesSaga);
Expand Down
20 changes: 0 additions & 20 deletions ts/sagas/startup/watchPinResetSaga.ts

This file was deleted.

23 changes: 20 additions & 3 deletions ts/screens/onboarding/PinScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ import { PinString } from "../../types/PinString";
import { setAccessibilityFocus } from "../../utils/accessibility";
import { setPin } from "../../utils/keychain";
import { maybeNotNullyString } from "../../utils/strings";
import { GlobalState } from "../../store/reducers/types";
import { isOnboardingCompletedSelector } from "../../store/reducers/navigationHistory";
import { instabugLog, TypeLogs } from "../../boot/configureInstabug";

type Props = NavigationScreenProps & ReturnType<typeof mapDispatchToProps>;
type Props = NavigationScreenProps &
ReturnType<typeof mapDispatchToProps> &
ReturnType<typeof mapStateToProps>;

type PinUnselected = {
state: "PinUnselected";
Expand Down Expand Up @@ -348,7 +352,11 @@ class PinScreen extends React.PureComponent<Props, State> {
);
}

private handleGoBack = () =>
private handleGoBack = () => {
if (this.props.isOnboardingCompleted) {
this.props.navigation.goBack();
return;
}
Alert.alert(
I18n.t("onboarding.alert.title"),
I18n.t("onboarding.alert.description"),
Expand All @@ -364,6 +372,7 @@ class PinScreen extends React.PureComponent<Props, State> {
}
]
);
};

public render() {
const { pinState } = this.state;
Expand Down Expand Up @@ -402,6 +411,10 @@ class PinScreen extends React.PureComponent<Props, State> {
});
instabugLog(`createPinSuccess`, TypeLogs.DEBUG, instabuglogTag);
this.props.createPinSuccess(pin);
// user is updating his/her pin inside the app, go back
if (this.props.isOnboardingCompleted) {
this.props.navigation.goBack();
}
},
_ => {
instabugLog(`setPin error`, TypeLogs.DEBUG, instabuglogTag);
Expand All @@ -425,9 +438,13 @@ class PinScreen extends React.PureComponent<Props, State> {
};
}

const mapStateToProps = (state: GlobalState) => ({
isOnboardingCompleted: isOnboardingCompletedSelector(state)
});

const mapDispatchToProps = (dispatch: Dispatch) => ({
createPinSuccess: (pin: PinString) => dispatch(createPinSuccess(pin)),
abortOnboarding: () => dispatch(abortOnboarding())
});

export default connect(undefined, mapDispatchToProps)(PinScreen);
export default connect(mapStateToProps, mapDispatchToProps)(PinScreen);
24 changes: 3 additions & 21 deletions ts/screens/profile/ProfileMainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
preferencesExperimentalFeaturesSetEnabled,
preferencesPagoPaTestEnvironmentSetEnabled
} from "../../store/actions/persistedPreferences";
import { startPinReset } from "../../store/actions/pinset";
import { updatePin } from "../../store/actions/pinset";
import { clearCache } from "../../store/actions/profile";
import { Dispatch } from "../../store/actions/types";
import {
Expand Down Expand Up @@ -329,24 +329,6 @@ class ProfileMainScreen extends React.PureComponent<Props, State> {
};
*/

private confirmResetAlert = () =>
Alert.alert(
I18n.t("profile.main.resetPin.confirmTitle"),
I18n.t("profile.main.resetPin.confirmMsg"),
[
{
text: I18n.t("global.buttons.cancel"),
style: "cancel"
},
{
text: I18n.t("global.buttons.confirm"),
style: "destructive",
onPress: this.props.resetPin
}
],
{ cancelable: false }
);

private ServiceListRef = React.createRef<ScrollView>();
private scrollToTop = () => {
if (this.ServiceListRef.current) {
Expand Down Expand Up @@ -420,7 +402,7 @@ class ProfileMainScreen extends React.PureComponent<Props, State> {
<ListItemComponent
title={I18n.t("identification.unlockCode.reset.button_short")}
subTitle={I18n.t("identification.unlockCode.reset.tip_short")}
onPress={this.confirmResetAlert}
onPress={this.props.resetPin}
hideIcon={true}
/>

Expand Down Expand Up @@ -584,7 +566,7 @@ const mapStateToProps = (state: GlobalState) => ({
const mapDispatchToProps = (dispatch: Dispatch) => ({
// hard-logout
logout: () => dispatch(logoutRequest({ keepUserData: false })),
resetPin: () => dispatch(startPinReset()),
resetPin: () => dispatch(updatePin()),
clearCache: () => dispatch(clearCache()),
setDebugModeEnabled: (enabled: boolean) =>
dispatch(setDebugModeEnabled(enabled)),
Expand Down
4 changes: 2 additions & 2 deletions ts/store/actions/pinset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import { ActionType, createStandardAction } from "typesafe-actions";
import { PinString } from "../../types/PinString";

export const startPinReset = createStandardAction("START_PIN_RESET")();
export const updatePin = createStandardAction("UPDATE_PIN")();

export const createPinSuccess = createStandardAction("CREATE_PIN_SUCCESS")<
PinString
>();

export type PinSetActions = ActionType<
typeof startPinReset | typeof createPinSuccess
typeof createPinSuccess | typeof updatePin
>;
3 changes: 2 additions & 1 deletion ts/store/middlewares/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {
updateNotificationsInstallationToken
} from "../actions/notifications";
import { tosAccepted } from "../actions/onboarding";
import { createPinSuccess } from "../actions/pinset";
import { createPinSuccess, updatePin } from "../actions/pinset";
import {
profileFirstLogin,
profileLoadFailure,
Expand Down Expand Up @@ -306,6 +306,7 @@ const trackAction = (mp: NonNullable<typeof mixpanel>) => (
// onboarding
case getType(analyticsOnboardingStarted):
case getType(createPinSuccess):
case getType(updatePin):
// profile
case getType(profileUpsert.success):
// userMetadata
Expand Down

0 comments on commit b7d1a46

Please sign in to comment.