From 4c432b57e41dc299031077877b9b380d11082fbc Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Mon, 10 Aug 2020 18:25:39 +0200 Subject: [PATCH 01/19] [#173888442] update react-native-webview --- ios/Podfile.lock | 4 ++-- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 03bd392f32d..c84d2b76615 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -289,7 +289,7 @@ PODS: - react-native-text-input-mask (2.0.0): - React - RNInputMask - - react-native-webview (8.0.0): + - react-native-webview (10.4.0): - React - React-RCTActionSheet (0.63.2): - React-Core/RCTActionSheetHeaders (= 0.63.2) @@ -677,7 +677,7 @@ SPEC CHECKSUMS: react-native-screen-brightness: 9eefe6db96a5d757e63cdfce8e48d7c9039f2af2 react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865 react-native-text-input-mask: 07227297075f9653315f43b0424d596423a01736 - react-native-webview: a75bffe77bc4efaab83d7b3af12007ad40cced09 + react-native-webview: 1ad70b21fb9e44811e33a99e43a4b68b94806a6d React-RCTActionSheet: 910163b6b09685a35c4ebbc52b66d1bfbbe39fc5 React-RCTAnimation: 9a883bbe1e9d2e158d4fb53765ed64c8dc2200c6 React-RCTBlob: 39cf0ece1927996c4466510e25d2105f67010e13 diff --git a/package.json b/package.json index 37dcbc338cd..3f94b428d9c 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "react-native-text-input-mask": "^2.0.0", "react-native-touch-id": "^4.4.1", "react-native-vector-icons": "^7.0.0", - "react-native-webview": "8.0.0", + "react-native-webview": "10.4.0", "react-navigation": "3.3.0", "react-navigation-redux-helpers": "^3.0.0", "react-redux": "6.0.0", diff --git a/yarn.lock b/yarn.lock index b846806119a..16392f37f8f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9413,10 +9413,10 @@ react-native-vector-icons@^7.0.0: prop-types "^15.7.2" yargs "^15.0.2" -react-native-webview@8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-8.0.0.tgz#95581856396c626db54284127428b50591e750c8" - integrity sha512-Shom5lT0hfD0oxzj7Wm0hdxXcsYcK38R3rwWT0UlL9dBjtucAPiAAFpOQX2wdxOSP5ApnCIdIiNnPTtPRepVMw== +react-native-webview@10.4.0: + version "10.4.0" + resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-10.4.0.tgz#81602b42618eb1b085074e5b16755610ca4bdadf" + integrity sha512-S+325GL+JgdoVuAxuYgtxJka8noBSKgy3RmxHAfjI0wM+bQrV4xK/lBSbVvB+zmILZqXdbuDCfjpuvKrx++xdQ== dependencies: escape-string-regexp "2.0.0" invariant "2.2.4" From fdcc0cdad674b391b7ce6a72f21ad4661a1860a9 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 11 Aug 2020 10:08:41 +0200 Subject: [PATCH 02/19] [#173917003] upgrade redux saga to 1.1.3 --- package.json | 5 +- patches/reactotron-redux-saga+2.1.4.patch | 17 ------ ts/__e2e__/app.e2e.ts | 2 +- .../store/sagas/handleBonusFromIdPolling.ts | 3 +- ts/sagas/identification.ts | 15 +++-- ts/sagas/installation.ts | 3 +- ts/sagas/messages/messages.ts | 3 +- ts/sagas/notifications.ts | 6 +- ts/sagas/preferences.ts | 2 +- ts/sagas/profile.ts | 7 +-- ts/sagas/startup.ts | 25 ++++---- ts/sagas/startup/authenticationSaga.ts | 3 +- ts/sagas/startup/checkAcceptedTosSaga.ts | 3 +- .../startup/checkAcknowledgedEmailSaga.ts | 3 +- .../checkAcknowledgedFingerprintSaga.ts | 6 +- ts/sagas/startup/checkConfiguredPinSaga.ts | 2 +- ts/sagas/startup/checkProfileEnabledSaga.ts | 2 +- .../startup/loadSessionInformationSaga.ts | 2 +- ts/sagas/startup/saveNavigationStateSaga.ts | 6 +- ts/sagas/startup/watchAbortOnboardingSaga.ts | 2 +- .../startup/watchApplicationActivitySaga.ts | 12 +++- .../watchLoadMessageWithRelationsSaga.ts | 10 ++- ts/sagas/startup/watchLoadMessagesSaga.ts | 13 ++-- ts/sagas/startup/watchLogoutSaga.ts | 3 +- ts/sagas/startup/watchNotificationSaga.ts | 5 +- ts/sagas/startup/watchPinResetSaga.ts | 3 +- ts/sagas/startup/watchSessionExpiredSaga.ts | 3 +- ts/sagas/wallet.ts | 36 +++++------ ts/sagas/wallet/pagopaApis.ts | 10 ++- ts/types/utils.ts | 2 +- ts/utils/SessionManager.ts | 2 +- yarn.lock | 61 +++---------------- 32 files changed, 102 insertions(+), 175 deletions(-) delete mode 100644 patches/reactotron-redux-saga+2.1.4.patch diff --git a/package.json b/package.json index 3f94b428d9c..24bb5d7eb22 100644 --- a/package.json +++ b/package.json @@ -95,11 +95,11 @@ "react-redux": "6.0.0", "reactotron-react-native": "^5.0.0", "reactotron-redux": "^3.1.3", - "reactotron-redux-saga": "2.1.4", + "reactotron-redux-saga": "4.2.3", "redux": "4.0.5", "redux-logger": "3.0.6", "redux-persist": "5.10.0", - "redux-saga": "0.16.2", + "redux-saga": "1.1.3", "remark": "10.0.1", "remark-custom-blocks": "2.3.1", "remark-html": "9.0.0", @@ -142,7 +142,6 @@ "@types/react-redux": "6.0.12", "@types/react-test-renderer": "16.0.3", "@types/redux-logger": "^3.0.6", - "@types/redux-saga": "^0.10.5", "@types/semver": "^6.2.0", "@types/stacktrace-js": "^0.0.32", "@types/uuid": "^3.4.4", diff --git a/patches/reactotron-redux-saga+2.1.4.patch b/patches/reactotron-redux-saga+2.1.4.patch deleted file mode 100644 index a0e2e7e49e5..00000000000 --- a/patches/reactotron-redux-saga+2.1.4.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/node_modules/reactotron-redux-saga/reactotron-redux-saga.d.ts b/node_modules/reactotron-redux-saga/reactotron-redux-saga.d.ts -index 5ee033d..863a35e 100644 ---- a/node_modules/reactotron-redux-saga/reactotron-redux-saga.d.ts -+++ b/node_modules/reactotron-redux-saga/reactotron-redux-saga.d.ts -@@ -1,12 +1,3 @@ --// Module Augmentation for plugin --declare module 'reactotron-react-native' { -- import { Monitor } from 'redux-saga'; -- -- export interface Reactotron { -- createSagaMonitor(): Monitor; -- } --} -- - declare module 'reactotron-redux-saga' { - import { ReactotronPlugin, Reactotron } from 'reactotron-react-native'; - diff --git a/ts/__e2e__/app.e2e.ts b/ts/__e2e__/app.e2e.ts index 0c94cec1562..780a4bb3e13 100644 --- a/ts/__e2e__/app.e2e.ts +++ b/ts/__e2e__/app.e2e.ts @@ -10,7 +10,7 @@ declare const by: Detox.Matchers; import * as detox from "detox"; import adapter from "detox/runners/jest/adapter"; -import { delay } from "redux-saga"; +import { delay } from "redux-saga/effects"; const config = require("package.json").detox; diff --git a/ts/features/bonusVacanze/store/sagas/handleBonusFromIdPolling.ts b/ts/features/bonusVacanze/store/sagas/handleBonusFromIdPolling.ts index 0c52d71bf53..fa60dc83a72 100644 --- a/ts/features/bonusVacanze/store/sagas/handleBonusFromIdPolling.ts +++ b/ts/features/bonusVacanze/store/sagas/handleBonusFromIdPolling.ts @@ -1,5 +1,6 @@ +import { SagaIterator } from "@redux-saga/core"; import { Millisecond } from "italia-ts-commons/lib/units"; -import { delay, SagaIterator } from "redux-saga"; +import { delay } from "redux-saga/effects"; import { call, put, race, take } from "redux-saga/effects"; import { ActionType, getType, isActionOf } from "typesafe-actions"; import { diff --git a/ts/sagas/identification.ts b/ts/sagas/identification.ts index b16c77e3ad2..4e868528f1b 100644 --- a/ts/sagas/identification.ts +++ b/ts/sagas/identification.ts @@ -1,5 +1,11 @@ -import { Effect } from "redux-saga"; -import { call, put, select, take, takeLatest } from "redux-saga/effects"; +import { + call, + Effect, + put, + select, + take, + takeLatest +} from "redux-saga/effects"; import { ActionType, getType } from "typesafe-actions"; import { startApplicationInitialization } from "../store/actions/application"; @@ -30,7 +36,6 @@ import { } from "../store/reducers/identification"; import { pendingMessageStateSelector } from "../store/reducers/notifications/pendingMessage"; import { paymentsCurrentStateSelector } from "../store/reducers/payments/current"; -import { GlobalState } from "../store/reducers/types"; import { isPaymentOngoingSelector } from "../store/reducers/wallet/payment"; import { PinString } from "../types/PinString"; import { SagaCallReturnType } from "../types/utils"; @@ -151,12 +156,12 @@ function* startAndHandleIdentificationResult( // Check if we have a pending notification message const pendingMessageState: ReturnType< typeof pendingMessageStateSelector - > = yield select(pendingMessageStateSelector); + > = yield select(pendingMessageStateSelector); // Check if there is a payment ongoing const isPaymentOngoing: ReturnType< typeof isPaymentOngoingSelector - > = yield select(isPaymentOngoingSelector); + > = yield select(isPaymentOngoingSelector); if (!isPaymentOngoing && pendingMessageState) { // We have a pending notification message to handle diff --git a/ts/sagas/installation.ts b/ts/sagas/installation.ts index f7f697ee537..ecf9911d54c 100644 --- a/ts/sagas/installation.ts +++ b/ts/sagas/installation.ts @@ -6,7 +6,6 @@ import { call, Effect, put, select } from "redux-saga/effects"; import { scheduleLocalNotificationsAccessSpid } from "../boot/scheduleLocalNotifications"; import { sessionInvalid } from "../store/actions/authentication"; import { isFirstRunAfterInstallSelector } from "../store/reducers/installation"; -import { GlobalState } from "../store/reducers/types"; import { deletePin } from "../utils/keychain"; /** @@ -18,7 +17,7 @@ export function* previousInstallationDataDeleteSaga(): IterableIterator< > { const isFirstRunAfterInstall: ReturnType< typeof isFirstRunAfterInstallSelector - > = yield select(isFirstRunAfterInstallSelector); + > = yield select(isFirstRunAfterInstallSelector); if (isFirstRunAfterInstall) { // Delete the current unlock code from the Keychain diff --git a/ts/sagas/messages/messages.ts b/ts/sagas/messages/messages.ts index 626a12d123b..9d498f4953d 100644 --- a/ts/sagas/messages/messages.ts +++ b/ts/sagas/messages/messages.ts @@ -11,7 +11,6 @@ import { CreatedMessageWithoutContent } from "../../../definitions/backend/Creat import { BackendClient } from "../../api/backend"; import { loadMessage as loadMessageAction } from "../../store/actions/messages"; import { messageStateByIdSelector } from "../../store/reducers/entities/messages/messagesById"; -import { GlobalState } from "../../store/reducers/types"; import { SagaCallReturnType } from "../../types/utils"; import { readablePrivacyReport } from "../../utils/reporters"; @@ -27,7 +26,7 @@ export function* loadMessage( // Load the messages already in the redux store const cachedMessage: ReturnType< ReturnType - > = yield select(messageStateByIdSelector(meta.id)); + > = yield select(messageStateByIdSelector(meta.id)); // If we already have the message in the store just return it if (cachedMessage !== undefined && pot.isSome(cachedMessage.message)) { diff --git a/ts/sagas/notifications.ts b/ts/sagas/notifications.ts index bbe2e553b3b..87c5b1f6815 100644 --- a/ts/sagas/notifications.ts +++ b/ts/sagas/notifications.ts @@ -1,17 +1,15 @@ /** * A saga to manage notifications */ +import { readableReport } from "italia-ts-commons/lib/reporters"; import { TypeOfApiResponseStatus } from "italia-ts-commons/lib/requests"; import { Platform } from "react-native"; import { call, Effect, put, select } from "redux-saga/effects"; - -import { readableReport } from "italia-ts-commons/lib/reporters"; import { PlatformEnum } from "../../definitions/backend/Platform"; import { CreateOrUpdateInstallationT } from "../../definitions/backend/requestTypes"; import { BackendClient } from "../api/backend"; import { updateNotificationInstallationFailure } from "../store/actions/notifications"; import { notificationsInstallationSelector } from "../store/reducers/notifications/installation"; -import { GlobalState } from "../store/reducers/types"; import { SagaCallReturnType } from "../types/utils"; const notificationsPlatform: PlatformEnum = Platform.select({ @@ -33,7 +31,7 @@ export function* updateInstallationSaga( // Get the notifications installation data from the store const notificationsInstallation: ReturnType< typeof notificationsInstallationSelector - > = yield select(notificationsInstallationSelector); + > = yield select(notificationsInstallationSelector); // Check if the notification server token is available (non available on iOS simulator) if (notificationsInstallation.token === undefined) { diff --git a/ts/sagas/preferences.ts b/ts/sagas/preferences.ts index 6b451fc62c1..f6ffe6c570c 100644 --- a/ts/sagas/preferences.ts +++ b/ts/sagas/preferences.ts @@ -1,6 +1,6 @@ import { getLanguages } from "react-native-i18n"; -import { Effect } from "redux-saga"; +import { Effect } from "redux-saga/effects"; import { call, put } from "redux-saga/effects"; import { preferencesLanguagesLoadSuccess } from "../store/actions/preferences"; import { SagaCallReturnType } from "../types/utils"; diff --git a/ts/sagas/profile.ts b/ts/sagas/profile.ts index a09bcc578ba..5c5fbbe1cdb 100644 --- a/ts/sagas/profile.ts +++ b/ts/sagas/profile.ts @@ -20,7 +20,6 @@ import { startEmailValidation } from "../store/actions/profile"; import { profileSelector } from "../store/reducers/profile"; -import { GlobalState } from "../store/reducers/types"; import { SagaCallReturnType } from "../types/utils"; // A saga to load the Profile. @@ -66,9 +65,9 @@ function* createOrUpdateProfileSaga( action: ActionType ): Iterator { // Get the current Profile from the state - const profileState: ReturnType = yield select< - GlobalState - >(profileSelector); + const profileState: ReturnType = yield select( + profileSelector + ); if (pot.isNone(profileState)) { // somewhing's wrong, we don't even have an AuthenticatedProfile meaning diff --git a/ts/sagas/startup.ts b/ts/sagas/startup.ts index c14eb715e1d..b02ea05e119 100644 --- a/ts/sagas/startup.ts +++ b/ts/sagas/startup.ts @@ -2,10 +2,10 @@ import { fromNullable, isNone, none, Option } from "fp-ts/lib/Option"; import * as pot from "italia-ts-commons/lib/pot"; import { Millisecond } from "italia-ts-commons/lib/units"; import { NavigationActions, NavigationState } from "react-navigation"; -import { Effect } from "redux-saga"; import { call, cancel, + Effect, fork, put, select, @@ -22,6 +22,8 @@ import { pagoPaApiUrlPrefix, pagoPaApiUrlPrefixTest } from "../config"; + +import { watchBonusSaga } from "../features/bonusVacanze/store/sagas/bonusSaga"; import { IdentityProvider } from "../models/IdentityProvider"; import AppNavigator from "../navigation/AppNavigator"; import { startApplicationInitialization } from "../store/actions/application"; @@ -46,14 +48,10 @@ import { navigationStateSelector } from "../store/reducers/navigation"; import { pendingMessageStateSelector } from "../store/reducers/notifications/pendingMessage"; import { isPagoPATestEnabledSelector } from "../store/reducers/persistedPreferences"; import { profileSelector } from "../store/reducers/profile"; -import { GlobalState } from "../store/reducers/types"; import { PinString } from "../types/PinString"; import { SagaCallReturnType } from "../types/utils"; import { deletePin, getPin } from "../utils/keychain"; import { startTimer } from "../utils/timer"; -import { watchProfileEmailValidationChangedSaga } from "./watchProfileEmailValidationChangedSaga"; - -import { watchBonusSaga } from "../features/bonusVacanze/store/sagas/bonusSaga"; import { startAndReturnIdentificationResult, watchIdentificationRequest @@ -91,6 +89,7 @@ import { watchUpserUserMetadata } from "./user/userMetadata"; import { watchWalletSaga } from "./wallet"; +import { watchProfileEmailValidationChangedSaga } from "./watchProfileEmailValidationChangedSaga"; const WAIT_INITIALIZE_SAGA = 3000 as Millisecond; /** @@ -113,7 +112,7 @@ export function* initializeApplicationSaga(): IterableIterator { // Get last logged in Profile from the state const lastLoggedInProfileState: ReturnType< typeof profileSelector - > = yield select(profileSelector); + > = yield select(profileSelector); const lastEmailValidated = pot.isSome(lastLoggedInProfileState) ? fromNullable(lastLoggedInProfileState.value.is_email_validated) @@ -129,7 +128,7 @@ export function* initializeApplicationSaga(): IterableIterator { // Whether the user is currently logged in. const previousSessionToken: ReturnType< typeof sessionTokenSelector - > = yield select(sessionTokenSelector); + > = yield select(sessionTokenSelector); // Unless we have a valid session token already, login until we have one. const sessionToken: SagaCallReturnType< @@ -175,7 +174,7 @@ export function* initializeApplicationSaga(): IterableIterator { // tslint:disable-next-line: no-let let maybeSessionInformation: ReturnType< typeof sessionInfoSelector - > = yield select(sessionInfoSelector); + > = yield select(sessionInfoSelector); if (isSessionRefreshed || maybeSessionInformation.isNone()) { // let's try to load the session information from the backend. maybeSessionInformation = yield call( @@ -224,9 +223,7 @@ export function* initializeApplicationSaga(): IterableIterator { yield put(clearCache()); } - const maybeIdp: Option = yield select( - idpSelector - ); + const maybeIdp: Option = yield select(idpSelector); setInstabugProfileAttributes(maybeIdp); @@ -315,7 +312,7 @@ export function* initializeApplicationSaga(): IterableIterator { const isPagoPATestEnabled: ReturnType< typeof isPagoPATestEnabledSelector - > = yield select(isPagoPATestEnabledSelector); + > = yield select(isPagoPATestEnabledSelector); yield fork( watchWalletSaga, @@ -373,7 +370,7 @@ export function* initializeApplicationSaga(): IterableIterator { // Check if we have a pending notification message const pendingMessageState: ReturnType< typeof pendingMessageStateSelector - > = yield select(pendingMessageStateSelector); + > = yield select(pendingMessageStateSelector); if (pendingMessageState) { // We have a pending notification message to handle @@ -385,7 +382,7 @@ export function* initializeApplicationSaga(): IterableIterator { // Navigate to message details screen yield put(navigateToMessageDetailScreenAction({ messageId })); // Push the MAIN navigator in the history to handle the back button - const navigationState: NavigationState = yield select( + const navigationState: NavigationState = yield select( navigationStateSelector ); yield put( diff --git a/ts/sagas/startup/authenticationSaga.ts b/ts/sagas/startup/authenticationSaga.ts index b1c2eefe825..3acb958b9df 100644 --- a/ts/sagas/startup/authenticationSaga.ts +++ b/ts/sagas/startup/authenticationSaga.ts @@ -1,5 +1,4 @@ -import { Effect } from "redux-saga"; -import { call, cancel, fork, put, take } from "redux-saga/effects"; +import { call, cancel, Effect, fork, put, take } from "redux-saga/effects"; import { ActionType, getType } from "typesafe-actions"; import { removeScheduledNotificationAccessSpid } from "../../boot/scheduleLocalNotifications"; import { diff --git a/ts/sagas/startup/checkAcceptedTosSaga.ts b/ts/sagas/startup/checkAcceptedTosSaga.ts index e32421ea893..b66b0e804a4 100644 --- a/ts/sagas/startup/checkAcceptedTosSaga.ts +++ b/ts/sagas/startup/checkAcceptedTosSaga.ts @@ -1,5 +1,4 @@ -import { Effect } from "redux-saga"; -import { call, put, take } from "redux-saga/effects"; +import { call, Effect, put, take } from "redux-saga/effects"; import { ActionType, getType } from "typesafe-actions"; import { InitializedProfile } from "../../../definitions/backend/InitializedProfile"; import { tosVersion } from "../../config"; diff --git a/ts/sagas/startup/checkAcknowledgedEmailSaga.ts b/ts/sagas/startup/checkAcknowledgedEmailSaga.ts index c888b232276..34ebcfae7a8 100644 --- a/ts/sagas/startup/checkAcknowledgedEmailSaga.ts +++ b/ts/sagas/startup/checkAcknowledgedEmailSaga.ts @@ -1,5 +1,4 @@ -import { Effect } from "redux-saga"; -import { put, take } from "redux-saga/effects"; +import { Effect, put, take } from "redux-saga/effects"; import { InitializedProfile } from "../../../definitions/backend/InitializedProfile"; import { navigateToEmailInsertScreen, diff --git a/ts/sagas/startup/checkAcknowledgedFingerprintSaga.ts b/ts/sagas/startup/checkAcknowledgedFingerprintSaga.ts index 32b468f4f96..453d86a7b29 100644 --- a/ts/sagas/startup/checkAcknowledgedFingerprintSaga.ts +++ b/ts/sagas/startup/checkAcknowledgedFingerprintSaga.ts @@ -1,11 +1,9 @@ import TouchID, { IsSupportedConfig } from "react-native-touch-id"; -import { Effect } from "redux-saga"; -import { call, put, select, take } from "redux-saga/effects"; +import { call, Effect, put, select, take } from "redux-saga/effects"; import { navigateToOnboardingFingerprintScreenAction } from "../../store/actions/navigation"; import { fingerprintAcknowledge } from "../../store/actions/onboarding"; import { preferenceFingerprintIsEnabledSaveSuccess } from "../../store/actions/persistedPreferences"; import { isFingerprintAcknowledgedSelector } from "../../store/reducers/onboarding"; -import { GlobalState } from "../../store/reducers/types"; export type BiometrySimpleType = | "FINGERPRINT" | "FACE_ID" @@ -74,7 +72,7 @@ export function* checkAcknowledgedFingerprintSaga(): IterableIterator { // recognition Screen. Consider that, like ToS, this should be displayed once. const isFingerprintAcknowledged: ReturnType< typeof isFingerprintAcknowledgedSelector - > = yield select(isFingerprintAcknowledgedSelector); + > = yield select(isFingerprintAcknowledgedSelector); if (!isFingerprintAcknowledged) { // Navigate to the FingerprintScreen and wait for acknowledgment diff --git a/ts/sagas/startup/checkConfiguredPinSaga.ts b/ts/sagas/startup/checkConfiguredPinSaga.ts index 6d28972935a..4f9a9b56cd5 100644 --- a/ts/sagas/startup/checkConfiguredPinSaga.ts +++ b/ts/sagas/startup/checkConfiguredPinSaga.ts @@ -1,5 +1,5 @@ import { Option } from "fp-ts/lib/Option"; -import { Effect } from "redux-saga"; +import { Effect } from "redux-saga/effects"; import { call, put, take } from "redux-saga/effects"; import { ActionType, getType } from "typesafe-actions"; diff --git a/ts/sagas/startup/checkProfileEnabledSaga.ts b/ts/sagas/startup/checkProfileEnabledSaga.ts index 49ade875855..210ef65f776 100644 --- a/ts/sagas/startup/checkProfileEnabledSaga.ts +++ b/ts/sagas/startup/checkProfileEnabledSaga.ts @@ -1,4 +1,4 @@ -import { Effect } from "redux-saga"; +import { Effect } from "redux-saga/effects"; import { put, take } from "redux-saga/effects"; import { ActionType, getType } from "typesafe-actions"; diff --git a/ts/sagas/startup/loadSessionInformationSaga.ts b/ts/sagas/startup/loadSessionInformationSaga.ts index 9a344fa5052..b433648d4f6 100644 --- a/ts/sagas/startup/loadSessionInformationSaga.ts +++ b/ts/sagas/startup/loadSessionInformationSaga.ts @@ -1,6 +1,6 @@ import { none, Option, some } from "fp-ts/lib/Option"; import { readableReport } from "italia-ts-commons/lib/reporters"; -import { Effect } from "redux-saga"; +import { Effect } from "redux-saga/effects"; import { call, put } from "redux-saga/effects"; import { PublicSession } from "../../../definitions/backend/PublicSession"; diff --git a/ts/sagas/startup/saveNavigationStateSaga.ts b/ts/sagas/startup/saveNavigationStateSaga.ts index d78afd0cd50..16071b2c475 100644 --- a/ts/sagas/startup/saveNavigationStateSaga.ts +++ b/ts/sagas/startup/saveNavigationStateSaga.ts @@ -1,12 +1,10 @@ import { NavigationParams, NavigationStateRoute } from "react-navigation"; -import { Effect } from "redux-saga"; -import { put, select } from "redux-saga/effects"; +import { Effect, put, select } from "redux-saga/effects"; import ROUTES from "../../navigation/routes"; import { setDeepLink } from "../../store/actions/deepLink"; import { navigationStateSelector } from "../../store/reducers/navigation"; -import { GlobalState } from "../../store/reducers/types"; /** * Saves the navigation state in the deep link state so that when the app @@ -17,7 +15,7 @@ import { GlobalState } from "../../store/reducers/types"; export function* saveNavigationStateSaga(): IterableIterator { const navigationState: ReturnType< typeof navigationStateSelector - > = yield select(navigationStateSelector); + > = yield select(navigationStateSelector); const currentRoute = navigationState.routes[ navigationState.index ] as NavigationStateRoute; diff --git a/ts/sagas/startup/watchAbortOnboardingSaga.ts b/ts/sagas/startup/watchAbortOnboardingSaga.ts index 9926926379a..a90d4580ede 100644 --- a/ts/sagas/startup/watchAbortOnboardingSaga.ts +++ b/ts/sagas/startup/watchAbortOnboardingSaga.ts @@ -1,4 +1,4 @@ -import { Effect } from "redux-saga"; +import { Effect } from "redux-saga/effects"; import { call, put, take } from "redux-saga/effects"; import { getType } from "typesafe-actions"; diff --git a/ts/sagas/startup/watchApplicationActivitySaga.ts b/ts/sagas/startup/watchApplicationActivitySaga.ts index 4d9bb2b8d59..2421243842e 100644 --- a/ts/sagas/startup/watchApplicationActivitySaga.ts +++ b/ts/sagas/startup/watchApplicationActivitySaga.ts @@ -1,5 +1,13 @@ -import { Effect, Task } from "redux-saga"; -import { call, cancel, fork, put, select, takeEvery } from "redux-saga/effects"; +import { Task } from "redux-saga"; +import { + call, + cancel, + Effect, + fork, + put, + select, + takeEvery +} from "redux-saga/effects"; import { ActionType, getType } from "typesafe-actions"; import { backgroundActivityTimeout } from "../../config"; import ROUTES from "../../navigation/routes"; diff --git a/ts/sagas/startup/watchLoadMessageWithRelationsSaga.ts b/ts/sagas/startup/watchLoadMessageWithRelationsSaga.ts index 376ae210f92..eef2c6341bf 100644 --- a/ts/sagas/startup/watchLoadMessageWithRelationsSaga.ts +++ b/ts/sagas/startup/watchLoadMessageWithRelationsSaga.ts @@ -1,12 +1,10 @@ import * as pot from "italia-ts-commons/lib/pot"; -import { Effect } from "redux-saga"; -import { call, put, select } from "redux-saga/effects"; +import { call, Effect, put, select } from "redux-saga/effects"; import { ActionType } from "typesafe-actions"; import { BackendClient } from "../../api/backend"; import { loadMessageWithRelations } from "../../store/actions/messages"; import { loadServiceDetail } from "../../store/actions/services"; import { serviceByIdSelector } from "../../store/reducers/entities/services/servicesById"; -import { GlobalState } from "../../store/reducers/types"; import { SagaCallReturnType } from "../../types/utils"; import { loadMessage } from "../messages/messages"; @@ -38,9 +36,9 @@ export function* loadMessageWithRelationsSaga( const serviceById = serviceByIdSelector(message.sender_service_id); - const potService: ReturnType = yield select< - GlobalState - >(serviceById); + const potService: ReturnType = yield select( + serviceById + ); // We have the message try to load also the sender service only if there's // no such service or if we are already loading it diff --git a/ts/sagas/startup/watchLoadMessagesSaga.ts b/ts/sagas/startup/watchLoadMessagesSaga.ts index 70f3b29fb86..554e456aaa8 100644 --- a/ts/sagas/startup/watchLoadMessagesSaga.ts +++ b/ts/sagas/startup/watchLoadMessagesSaga.ts @@ -4,6 +4,8 @@ import { none, Option, some } from "fp-ts/lib/Option"; import * as pot from "italia-ts-commons/lib/pot"; + +import { readableReport } from "italia-ts-commons/lib/reporters"; import { Task } from "redux-saga"; import { all, @@ -18,8 +20,6 @@ import { } from "redux-saga/effects"; import { ActionType, getType, isActionOf } from "typesafe-actions"; import { BackendClient } from "../../api/backend"; - -import { readableReport } from "italia-ts-commons/lib/reporters"; import { sessionExpired } from "../../store/actions/authentication"; import { loadMessage as loadMessageAction, @@ -33,7 +33,6 @@ import { messagesAllIdsSelector } from "../../store/reducers/entities/messages/m import { messagesStateByIdSelector } from "../../store/reducers/entities/messages/messagesById"; import { messagesStatusSelector } from "../../store/reducers/entities/messages/messagesStatus"; import { servicesByIdSelector } from "../../store/reducers/entities/services/servicesById"; -import { GlobalState } from "../../store/reducers/types"; import { SagaCallReturnType } from "../../types/utils"; import { uniqueItem } from "../../utils/enumerables"; @@ -80,7 +79,7 @@ export function* loadMessages( // Load already cached messages ids from the store const potCachedMessagesAllIds: ReturnType< typeof messagesAllIdsSelector - > = yield select(messagesAllIdsSelector); + > = yield select(messagesAllIdsSelector); const cachedMessagesAllIds = pot.getOrElse(potCachedMessagesAllIds, []); // Calculate the ids of the message no more visible that we need @@ -92,7 +91,7 @@ export function* loadMessages( // Load already cached messages status ids from the store const messagesStatusMapping: ReturnType< typeof messagesStatusSelector - > = yield select(messagesStatusSelector); + > = yield select(messagesStatusSelector); const messagesStatusIds = Object.keys(messagesStatusMapping).filter( _ => responseItemsIds.indexOf(_) < 0 ); @@ -117,7 +116,7 @@ export function* loadMessages( // Load already cached messages from the store const cachedMessagesById: ReturnType< typeof messagesStateByIdSelector - > = yield select(messagesStateByIdSelector); + > = yield select(messagesStateByIdSelector); const shouldLoadMessage = (message: { id: string }) => { const cached = cachedMessagesById[message.id]; @@ -134,7 +133,7 @@ export function* loadMessages( // Load already cached services from the store const cachedServicesById: ReturnType< typeof servicesByIdSelector - > = yield select(servicesByIdSelector); + > = yield select(servicesByIdSelector); const shouldLoadService = (id: string) => { const cached = cachedServicesById[id]; diff --git a/ts/sagas/startup/watchLogoutSaga.ts b/ts/sagas/startup/watchLogoutSaga.ts index 7e69832f068..a6d1b7d706b 100644 --- a/ts/sagas/startup/watchLogoutSaga.ts +++ b/ts/sagas/startup/watchLogoutSaga.ts @@ -1,6 +1,5 @@ import { readableReport } from "italia-ts-commons/lib/reporters"; -import { Effect } from "redux-saga"; -import { call, put, takeEvery } from "redux-saga/effects"; +import { call, Effect, put, takeEvery } from "redux-saga/effects"; import { ActionType, getType } from "typesafe-actions"; import { BackendClient } from "../../api/backend"; import { startApplicationInitialization } from "../../store/actions/application"; diff --git a/ts/sagas/startup/watchNotificationSaga.ts b/ts/sagas/startup/watchNotificationSaga.ts index 55c8ef041f1..8c037e1451e 100644 --- a/ts/sagas/startup/watchNotificationSaga.ts +++ b/ts/sagas/startup/watchNotificationSaga.ts @@ -4,7 +4,6 @@ import { ApplicationState } from "../../store/actions/application"; import { navigateToMessageDetailScreenAction } from "../../store/actions/navigation"; import { clearNotificationPendingMessage } from "../../store/actions/notifications"; import { pendingMessageStateSelector } from "../../store/reducers/notifications/pendingMessage"; -import { GlobalState } from "../../store/reducers/types"; import { isPaymentOngoingSelector } from "../../store/reducers/wallet/payment"; /** @@ -21,12 +20,12 @@ export function* watchNotificationSaga( // Check if there is a payment ongoing const isPaymentOngoing: ReturnType< typeof isPaymentOngoingSelector - > = yield select(isPaymentOngoingSelector); + > = yield select(isPaymentOngoingSelector); // Check if we have a pending notification message const pendingMessageState: ReturnType< typeof pendingMessageStateSelector - > = yield select(pendingMessageStateSelector); + > = yield select(pendingMessageStateSelector); // We only navigate to the new message from a push if we're not in a // payment flow diff --git a/ts/sagas/startup/watchPinResetSaga.ts b/ts/sagas/startup/watchPinResetSaga.ts index 4feb8c246ec..5a659316894 100644 --- a/ts/sagas/startup/watchPinResetSaga.ts +++ b/ts/sagas/startup/watchPinResetSaga.ts @@ -1,5 +1,4 @@ -import { Effect } from "redux-saga"; -import { call, put, takeEvery } from "redux-saga/effects"; +import { call, Effect, put, takeEvery } from "redux-saga/effects"; import { getType } from "typesafe-actions"; import { startApplicationInitialization } from "../../store/actions/application"; diff --git a/ts/sagas/startup/watchSessionExpiredSaga.ts b/ts/sagas/startup/watchSessionExpiredSaga.ts index 98caa0debfd..70f53ee8677 100644 --- a/ts/sagas/startup/watchSessionExpiredSaga.ts +++ b/ts/sagas/startup/watchSessionExpiredSaga.ts @@ -1,5 +1,4 @@ -import { Effect } from "redux-saga"; -import { call, put, select, takeLatest } from "redux-saga/effects"; +import { call, Effect, put, select, takeLatest } from "redux-saga/effects"; import { getType } from "typesafe-actions"; import { startApplicationInitialization } from "../../store/actions/application"; import { diff --git a/ts/sagas/wallet.ts b/ts/sagas/wallet.ts index e1cf7dd5ed9..6c22fa8366d 100644 --- a/ts/sagas/wallet.ts +++ b/ts/sagas/wallet.ts @@ -6,9 +6,11 @@ import { none, some } from "fp-ts/lib/Option"; import * as pot from "italia-ts-commons/lib/pot"; -import { delay } from "redux-saga"; + +import { DeferredPromise } from "italia-ts-commons/lib/promises"; import { call, + delay, Effect, fork, put, @@ -27,7 +29,9 @@ import { fetchPagoPaTimeout, fetchPaymentManagerLongTimeout } from "../config"; +import ROUTES from "../navigation/routes"; import { navigateBack } from "../store/actions/navigation"; +import { profileLoadSuccess, profileUpsert } from "../store/actions/profile"; import { backToEntrypointPayment, paymentAttiva, @@ -71,6 +75,7 @@ import { setFavouriteWalletRequest, setWalletSessionEnabled } from "../store/actions/wallet/wallets"; +import { isProfileEmailValidatedSelector } from "../store/reducers/profile"; import { GlobalState } from "../store/reducers/types"; import { @@ -81,11 +86,6 @@ import { import { SessionToken } from "../types/SessionToken"; import { defaultRetryingFetch } from "../utils/fetch"; - -import { DeferredPromise } from "italia-ts-commons/lib/promises"; -import ROUTES from "../navigation/routes"; -import { profileLoadSuccess, profileUpsert } from "../store/actions/profile"; -import { isProfileEmailValidatedSelector } from "../store/reducers/profile"; import { getCurrentRouteKey, getCurrentRouteName } from "../utils/navigation"; import { SessionManager } from "../utils/SessionManager"; import { paymentsDeleteUncompletedSaga } from "./payments"; @@ -156,7 +156,7 @@ function* startOrResumeAddCreditCardSaga( while (true) { // before each step we select the updated payment state to know what has // been already done. - const state: GlobalState["wallet"]["wallets"] = yield select( + const state: GlobalState["wallet"]["wallets"] = yield select( _ => _.wallet.wallets ); @@ -331,9 +331,9 @@ function* startOrResumePaymentActivationSaga( while (true) { // before each step we select the updated payment state to know what has // been already done. - const paymentState: GlobalState["wallet"]["payment"] = yield select< - GlobalState - >(_ => _.wallet.payment); + const paymentState: GlobalState["wallet"]["payment"] = yield select( + _ => _.wallet.payment + ); // first step: Attiva if (pot.isNone(paymentState.attiva)) { @@ -453,9 +453,9 @@ function* pollTransactionSaga( * This is a best effort operation as the result is actually ignored. */ function* deleteActivePaymentSaga() { - const potPaymentId: GlobalState["wallet"]["payment"]["paymentId"] = yield select< - GlobalState - >(_ => _.wallet.payment.paymentId); + const potPaymentId: GlobalState["wallet"]["payment"]["paymentId"] = yield select( + _ => _.wallet.payment.paymentId + ); const maybePaymentId = pot.toOption(potPaymentId); // stop polling shouldAbortPaymentIdPollingRequest.e2(true); @@ -528,7 +528,7 @@ export function* watchWalletSaga( // has an email address validated const isEmailValidated: ReturnType< typeof isProfileEmailValidatedSelector - > = yield select(isProfileEmailValidatedSelector); + > = yield select(isProfileEmailValidatedSelector); yield call(pmSessionManager.setSessionEnabled, isEmailValidated); // // Sagas @@ -729,7 +729,7 @@ function* setWalletSessionEnabledSaga( */ export function* watchPaymentInitializeSaga(): Iterator { yield takeEvery(getType(paymentInitializeState), function*() { - const nav: GlobalState["nav"] = yield select(_ => _.nav); + const nav: GlobalState["nav"] = yield select(_ => _.nav); const currentRouteName = getCurrentRouteName(nav); const currentRouteKey = getCurrentRouteKey(nav); if (currentRouteName !== undefined && currentRouteKey !== undefined) { @@ -750,9 +750,9 @@ export function* watchPaymentInitializeSaga(): Iterator { */ export function* watchBackToEntrypointPaymentSaga(): Iterator { yield takeEvery(getType(backToEntrypointPayment), function*() { - const entrypointRoute: GlobalState["wallet"]["payment"]["entrypointRoute"] = yield select< - GlobalState - >(_ => _.wallet.payment.entrypointRoute); + const entrypointRoute: GlobalState["wallet"]["payment"]["entrypointRoute"] = yield select( + _ => _.wallet.payment.entrypointRoute + ); if (entrypointRoute !== undefined) { const key = entrypointRoute ? entrypointRoute.key : undefined; const routeName = entrypointRoute ? entrypointRoute.name : undefined; diff --git a/ts/sagas/wallet/pagopaApis.ts b/ts/sagas/wallet/pagopaApis.ts index b040d6c57a6..e5345657421 100644 --- a/ts/sagas/wallet/pagopaApis.ts +++ b/ts/sagas/wallet/pagopaApis.ts @@ -1,8 +1,7 @@ +import { fromNullable } from "fp-ts/lib/Option"; import { RptIdFromString } from "italia-pagopa-commons/lib/pagopa"; import { call, Effect, put, select } from "redux-saga/effects"; import { ActionType } from "typesafe-actions"; - -import { fromNullable } from "fp-ts/lib/Option"; import { BackendClient } from "../../api/backend"; import { PaymentManagerClient } from "../../api/pagopa"; import { checkCurrentSession } from "../../store/actions/authentication"; @@ -43,7 +42,6 @@ import { setFavouriteWalletSuccess } from "../../store/actions/wallet/wallets"; import { isPagoPATestEnabledSelector } from "../../store/reducers/persistedPreferences"; -import { GlobalState } from "../../store/reducers/types"; import { PaymentManagerToken } from "../../types/pagopa"; import { SagaCallReturnType } from "../../types/utils"; import { readablePrivacyReport } from "../../utils/reporters"; @@ -617,7 +615,7 @@ export function* paymentVerificaRequestHandler( try { const isPagoPATestEnabled: ReturnType< typeof isPagoPATestEnabledSelector - > = yield select(isPagoPATestEnabledSelector); + > = yield select(isPagoPATestEnabledSelector); const response: SagaCallReturnType = yield call( getVerificaRpt, @@ -656,7 +654,7 @@ export function* paymentAttivaRequestHandler( try { const isPagoPATestEnabled: ReturnType< typeof isPagoPATestEnabledSelector - > = yield select(isPagoPATestEnabledSelector); + > = yield select(isPagoPATestEnabledSelector); const response: SagaCallReturnType = yield call( postAttivaRpt, @@ -705,7 +703,7 @@ export function* paymentIdPollingRequestHandler( try { const isPagoPATestEnabled: ReturnType< typeof isPagoPATestEnabledSelector - > = yield select(isPagoPATestEnabledSelector); + > = yield select(isPagoPATestEnabledSelector); const getPaymentId = getPaymentIdApi.e2; const response: SagaCallReturnType = yield call( diff --git a/ts/types/utils.ts b/ts/types/utils.ts index 730387115d3..122c0d64a03 100644 --- a/ts/types/utils.ts +++ b/ts/types/utils.ts @@ -1,7 +1,7 @@ // tslint:disable:readonly-array import { Pot } from "italia-ts-commons/lib/pot"; -import { Effect } from "redux-saga"; +import { Effect } from "redux-saga/effects"; import { PayloadAC, PayloadMetaAC } from "typesafe-actions/dist/type-helpers"; export type SagaCallReturnType< diff --git a/ts/utils/SessionManager.ts b/ts/utils/SessionManager.ts index a1f7e2f0986..be6c1c14743 100644 --- a/ts/utils/SessionManager.ts +++ b/ts/utils/SessionManager.ts @@ -5,7 +5,7 @@ import { Function1, Lazy } from "fp-ts/lib/function"; import { fromNullable, Option } from "fp-ts/lib/Option"; import * as t from "io-ts"; import { IResponseType } from "italia-ts-commons/lib/requests"; -import { delay } from "redux-saga"; +import { delay } from "redux-saga/effects"; /** * Provides the logic for caching and updating a session token by wrapping diff --git a/yarn.lock b/yarn.lock index 16392f37f8f..c3f42837d30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1647,13 +1647,6 @@ dependencies: redux "^4.0.0" -"@types/redux-saga@^0.10.5": - version "0.10.5" - resolved "https://registry.yarnpkg.com/@types/redux-saga/-/redux-saga-0.10.5.tgz#80bf21078379ebc97387dbe56e44467b5677fa85" - integrity sha1-gL8hB4N568lzh9vlbkRGe1Z3+oU= - dependencies: - redux-saga "*" - "@types/semver@^6.2.0": version "6.2.1" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.1.tgz#a236185670a7860f1597cf73bea2e16d001461ba" @@ -7059,11 +7052,6 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" -lodash-es@^4.2.1: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.15.tgz#21bd96839354412f23d7a10340e5eac6ee455d78" - integrity sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ== - lodash._reinterpolate@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" @@ -7184,7 +7172,7 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1: +lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.6.1: version "4.17.19" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== @@ -9067,18 +9055,6 @@ raf@^3.1.0: dependencies: performance-now "^2.1.0" -ramda@^0.24.1: - version "0.24.1" - resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.24.1.tgz#c3b7755197f35b8dc3502228262c4c91ddb6b857" - integrity sha1-w7d1UZfzW43DUCIoJixMkd22uFc= - -ramdasauce@^2.0.0: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ramdasauce/-/ramdasauce-2.1.3.tgz#acb45ecc7e4fc4d6f39e19989b4a16dff383e9c2" - integrity sha512-Ml3CPim4SKwmg5g9UI77lnRSeKr/kQw7YhQ6rfdMcBYy6DMlwmkEwQqjygJ3OhxPR+NfFfpjKl3Tf8GXckaqqg== - dependencies: - ramda "^0.24.1" - random-bytes@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/random-bytes/-/random-bytes-1.0.0.tgz#4f68a1dc0ae58bd3fb95848c30324db75d64360b" @@ -9565,7 +9541,7 @@ react@16.13.1: object-assign "^4.1.1" prop-types "^15.6.2" -reactotron-core-client@2.8.10, reactotron-core-client@^2.1.4: +reactotron-core-client@2.8.10: version "2.8.10" resolved "https://registry.yarnpkg.com/reactotron-core-client/-/reactotron-core-client-2.8.10.tgz#798f2a7aa9fd7e18e7a510531a613e8ae3008eb0" integrity sha512-SYRO4OCutJzfWMnaULUGVyETZnMDCU5ECNflXyM3Z5Gnfxp/wV6d7jYonhfxHdpU/aGb4Eg15C22myOCXSu6HQ== @@ -9582,16 +9558,10 @@ reactotron-react-native@^5.0.0: optionalDependencies: react-native-flipper "^0.34.0" -reactotron-redux-saga@2.1.4: - version "2.1.4" - resolved "https://registry.yarnpkg.com/reactotron-redux-saga/-/reactotron-redux-saga-2.1.4.tgz#6ec8dc997c45bc5d214615b422a231c8f51de7f0" - integrity sha512-IZFE9sN9lVLY2f/EbzqZ9Zq7jmc3bvWjgeIwKiDmepafrM5Gv7Ymii5vrwCsIX4zmrDX7yNJmZpoZbh36E4Qng== - dependencies: - ramda "^0.24.1" - ramdasauce "^2.0.0" - reactotron-core-client "^2.1.4" - redux "^3.7.1" - redux-saga "^0.16.1" +reactotron-redux-saga@4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/reactotron-redux-saga/-/reactotron-redux-saga-4.2.3.tgz#13071f792be987f47b89cae8c29a8e7254d8383d" + integrity sha512-Vo/zjwYyd93nT4h4SJkvhE5WIBk7AnZg5NPM0NF3auwPEz78ZR2xnnyCt2JPYFSvyy6ykNpS7vA7FeREgFkNCQ== reactotron-redux@^3.1.3: version "3.1.3" @@ -9745,18 +9715,13 @@ redux-saga-test-plan@^3.7.0: object-assign "^4.1.0" util-inspect "^0.1.8" -redux-saga@*, redux-saga@^1.0.2: +redux-saga@1.1.3, redux-saga@^1.0.2: version "1.1.3" resolved "https://registry.yarnpkg.com/redux-saga/-/redux-saga-1.1.3.tgz#9f3e6aebd3c994bbc0f6901a625f9a42b51d1112" integrity sha512-RkSn/z0mwaSa5/xH/hQLo8gNf4tlvT18qXDNvedihLcfzh+jMchDgaariQoehCpgRltEm4zHKJyINEz6aqswTw== dependencies: "@redux-saga/core" "^1.1.3" -redux-saga@0.16.2, redux-saga@^0.16.1: - version "0.16.2" - resolved "https://registry.yarnpkg.com/redux-saga/-/redux-saga-0.16.2.tgz#993662e86bc945d8509ac2b8daba3a8c615cc971" - integrity sha512-iIjKnRThI5sKPEASpUvySemjzwqwI13e3qP7oLub+FycCRDysLSAOwt958niZW6LhxfmS6Qm1BzbU70w/Koc4w== - redux@4.0.5, redux@4.x, redux@^4.0.0, redux@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f" @@ -9765,16 +9730,6 @@ redux@4.0.5, redux@4.x, redux@^4.0.0, redux@^4.0.4: loose-envify "^1.4.0" symbol-observable "^1.2.0" -redux@^3.7.1: - version "3.7.2" - resolved "https://registry.yarnpkg.com/redux/-/redux-3.7.2.tgz#06b73123215901d25d065be342eb026bc1c8537b" - integrity sha512-pNqnf9q1hI5HHZRBkj3bAngGZW/JMCmexDlOxw4XagXY2o1327nHH54LoTjiPJ0gizoqPDRqWyX/00g0hD6w+A== - dependencies: - lodash "^4.2.1" - lodash-es "^4.2.1" - loose-envify "^1.1.0" - symbol-observable "^1.0.3" - regenerate-unicode-properties@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" @@ -10976,7 +10931,7 @@ symbol-observable@1.0.1: resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4" integrity sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ= -symbol-observable@^1.0.3, symbol-observable@^1.2.0: +symbol-observable@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== From 6e695753fa2f84bf359d6a22fcbe9c88fead3ed2 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 11 Aug 2020 10:25:06 +0200 Subject: [PATCH 03/19] fix all typescript errors --- package.json | 1 + ts/sagas/backendInfo.ts | 2 +- ts/sagas/index.ts | 4 ++-- ts/sagas/preferences.ts | 3 +-- ts/sagas/startup/__tests__/authenticationSaga.test.ts | 2 +- yarn.lock | 8 ++++++++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 24bb5d7eb22..8e9cc548792 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "dependencies": { "@pagopa/react-native-cie": "0.2.2", "@react-native-community/async-storage": "^1.6.1", + "@redux-saga/testing-utils": "^1.1.3", "abort-controller": "^1.0.2", "async-mutex": "^0.1.3", "buffer": "^4.9.1", diff --git a/ts/sagas/backendInfo.ts b/ts/sagas/backendInfo.ts index 827342d1ea2..59169ab4e88 100644 --- a/ts/sagas/backendInfo.ts +++ b/ts/sagas/backendInfo.ts @@ -38,7 +38,7 @@ function* backendInfoWatcher(): IterableIterator { try { const backendInfoResponse: SagaCallReturnType< typeof getServerInfo - > = yield call(getServerInfo, {}); + > = yield call(getServerInfo); if ( backendInfoResponse.isRight() && backendInfoResponse.value.status === 200 diff --git a/ts/sagas/index.ts b/ts/sagas/index.ts index c7deaf7964c..208de365370 100644 --- a/ts/sagas/index.ts +++ b/ts/sagas/index.ts @@ -1,7 +1,7 @@ /** * The root saga that forks and includes all the other sagas. */ -import { all, call, Effect } from "redux-saga/effects"; +import { all, call } from "redux-saga/effects"; import backendInfoSaga from "./backendInfo"; import backendStatusSaga from "./backendStatus"; @@ -30,7 +30,7 @@ const connectionMonitorParameters = { }; */ -export default function* root(): Iterator { +export default function* root() { yield all([ call(startupSaga), // this saga is temporary removed since it seems to not work properly diff --git a/ts/sagas/preferences.ts b/ts/sagas/preferences.ts index f6ffe6c570c..f4a51b24385 100644 --- a/ts/sagas/preferences.ts +++ b/ts/sagas/preferences.ts @@ -10,8 +10,7 @@ import { SagaCallReturnType } from "../types/utils"; */ export function* loadSystemPreferencesSaga(): IterableIterator { const languages: SagaCallReturnType = yield call( - getLanguages, - {} + getLanguages ); yield put(preferencesLanguagesLoadSuccess(languages)); diff --git a/ts/sagas/startup/__tests__/authenticationSaga.test.ts b/ts/sagas/startup/__tests__/authenticationSaga.test.ts index e429618b2a8..9549faeabef 100644 --- a/ts/sagas/startup/__tests__/authenticationSaga.test.ts +++ b/ts/sagas/startup/__tests__/authenticationSaga.test.ts @@ -1,6 +1,6 @@ +import { createMockTask } from "@redux-saga/testing-utils"; import { Task } from "redux-saga"; import { testSaga } from "redux-saga-test-plan"; -import { createMockTask } from "redux-saga/utils"; import { getType } from "typesafe-actions"; import { removeScheduledNotificationAccessSpid } from "../../../boot/scheduleLocalNotifications"; import { diff --git a/yarn.lock b/yarn.lock index c3f42837d30..00a52cbbb95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1347,6 +1347,14 @@ resolved "https://registry.yarnpkg.com/@redux-saga/symbols/-/symbols-1.1.2.tgz#216a672a487fc256872b8034835afc22a2d0595d" integrity sha512-EfdGnF423glv3uMwLsGAtE6bg+R9MdqlHEzExnfagXPrIiuxwr3bdiAwz3gi+PsrQ3yBlaBpfGLtDG8rf3LgQQ== +"@redux-saga/testing-utils@^1.1.3": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@redux-saga/testing-utils/-/testing-utils-1.1.3.tgz#0148b7bfa541cb69ee144e1a2e79a53813c54560" + integrity sha512-MGMcBHgt80CoC8s8i0Mc7svGJPysS9qkJuAINlg+NvudLZcV23myd+H4uaXA4zmiLf16C4M+97b+e6wFoTaGcw== + dependencies: + "@redux-saga/symbols" "^1.1.2" + "@redux-saga/types" "^1.1.0" + "@redux-saga/types@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@redux-saga/types/-/types-1.1.0.tgz#0e81ce56b4883b4b2a3001ebe1ab298b84237204" From e67ee75acebb0b68d74c3713affed79affc973b8 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 11 Aug 2020 10:56:45 +0200 Subject: [PATCH 04/19] fix delay --- .../bonusVacanze/store/sagas/handleBonusFromIdPolling.ts | 2 +- ts/sagas/wallet.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ts/features/bonusVacanze/store/sagas/handleBonusFromIdPolling.ts b/ts/features/bonusVacanze/store/sagas/handleBonusFromIdPolling.ts index fa60dc83a72..da829206dd9 100644 --- a/ts/features/bonusVacanze/store/sagas/handleBonusFromIdPolling.ts +++ b/ts/features/bonusVacanze/store/sagas/handleBonusFromIdPolling.ts @@ -26,7 +26,7 @@ export function* bonusFromIdWorker(bonusId: string): SagaIterator { if (isActionOf(loadBonusVacanzeFromId.failure, resultAction)) { yield put(cancelLoadBonusFromIdPolling()); } - yield call(delay, POLLING_FREQ_TIMEOUT); + yield delay(POLLING_FREQ_TIMEOUT); } } /** diff --git a/ts/sagas/wallet.ts b/ts/sagas/wallet.ts index 6c22fa8366d..1795c9df50c 100644 --- a/ts/sagas/wallet.ts +++ b/ts/sagas/wallet.ts @@ -435,7 +435,7 @@ function* pollTransactionSaga( // on failure, try again after a delay // tslint:disable-next-line:saga-yield-return-type - yield call(delay, POLL_TRANSACTION_DELAY_MILLIS); + yield delay(POLL_TRANSACTION_DELAY_MILLIS); count -= 1; } From d07d29fd40f4b18d67938f371214d5f9e3e1b03d Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 11 Aug 2020 12:15:32 +0200 Subject: [PATCH 05/19] fix lint --- ts/__e2e__/app.e2e.ts | 6 ++++-- ts/utils/SessionManager.ts | 12 ++++++++---- ts/utils/timer.ts | 4 ++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ts/__e2e__/app.e2e.ts b/ts/__e2e__/app.e2e.ts index 780a4bb3e13..c9488dc2758 100644 --- a/ts/__e2e__/app.e2e.ts +++ b/ts/__e2e__/app.e2e.ts @@ -10,7 +10,8 @@ declare const by: Detox.Matchers; import * as detox from "detox"; import adapter from "detox/runners/jest/adapter"; -import { delay } from "redux-saga/effects"; +import { Millisecond } from "italia-ts-commons/lib/units"; +import { delayAsync } from "../utils/timer"; const config = require("package.json").detox; @@ -76,6 +77,7 @@ describe("e2e app", () => { .toBeVisible() .withTimeout(WAIT_TIMEOUT_MS); await expect(element(by.id("back-button"))).toBeVisible(); - await delay(5 * 1000); // wait 10s to let webview load + const waitTime = (5 * 1000) as Millisecond; + await delayAsync(waitTime); // wait 10s to let webview load }); }); diff --git a/ts/utils/SessionManager.ts b/ts/utils/SessionManager.ts index be6c1c14743..df1cfd798cc 100644 --- a/ts/utils/SessionManager.ts +++ b/ts/utils/SessionManager.ts @@ -5,7 +5,8 @@ import { Function1, Lazy } from "fp-ts/lib/function"; import { fromNullable, Option } from "fp-ts/lib/Option"; import * as t from "io-ts"; import { IResponseType } from "italia-ts-commons/lib/requests"; -import { delay } from "redux-saga/effects"; +import { Millisecond } from "italia-ts-commons/lib/units"; +import { delayAsync } from "./timer"; /** * Provides the logic for caching and updating a session token by wrapping @@ -58,7 +59,7 @@ export class SessionManager { private setEnabledSession = async (enabled: boolean) => { await this.mutex.runExclusive(() => { this.isSessionEnabled = enabled; - if (this.isSessionEnabled === false) { + if (!this.isSessionEnabled) { this.token = undefined; } }); @@ -90,7 +91,7 @@ export class SessionManager { return async () => { let count = 0; while (count <= this.maxRetries) { - if (this.isSessionEnabled === false) { + if (!this.isSessionEnabled) { throw new Error( "cant perform any requests cause the session is not enabled" ); @@ -100,7 +101,10 @@ export class SessionManager { if (this.token === undefined) { // if the token is still undefined, the refresh failed, try again // with a random delay to prevent the dogpile effect - await delay(Math.ceil(Math.random() * 100) + 50); + const waitSeconds = (Math.ceil(Math.random() * 100) + + 50) as Millisecond; + + await delayAsync(waitSeconds); // TODO: add customizable retry/backoff policy (https://www.pivotaltracker.com/story/show/170819459) continue; } diff --git a/ts/utils/timer.ts b/ts/utils/timer.ts index af83e1b36d1..60d847ac0ab 100644 --- a/ts/utils/timer.ts +++ b/ts/utils/timer.ts @@ -1,3 +1,4 @@ +import { Millisecond } from "italia-ts-commons/lib/units"; import BackgroundTimer from "react-native-background-timer"; export function startTimer(t: number): Promise { @@ -6,3 +7,6 @@ export function startTimer(t: number): Promise { BackgroundTimer.setTimeout(resolve.bind(null), t); }); } + +export const delayAsync = (milliseconds: Millisecond) => + new Promise(r => setTimeout(r, milliseconds)); From bc5b85e6756497adea3b5346ab14075e243519d1 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 11 Aug 2020 12:20:24 +0200 Subject: [PATCH 06/19] fix lint --- ts/utils/timer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/utils/timer.ts b/ts/utils/timer.ts index 60d847ac0ab..df42fd363e4 100644 --- a/ts/utils/timer.ts +++ b/ts/utils/timer.ts @@ -9,4 +9,4 @@ export function startTimer(t: number): Promise { } export const delayAsync = (milliseconds: Millisecond) => - new Promise(r => setTimeout(r, milliseconds)); + new Promise(r => setTimeout(r, milliseconds)); From a016436ff90b18cd3eceea8fb0cb8965904ee3cf Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 11 Aug 2020 14:11:11 +0200 Subject: [PATCH 07/19] fix saga test --- package.json | 2 +- .../__tests__/handleBonusActivationTests.ts | 6 ++++- ts/sagas/messages/__tests__/messages.test.ts | 22 +++++++++---------- .../loadServiceDetailRequestHandler.test.ts | 7 +++--- .../__tests__/watchCheckSessionSaga.test.ts | 10 +++++---- .../__tests__/watchLoadMessages.test.ts | 16 ++++---------- .../loadServiceDetailRequestHandler.ts | 2 +- .../user/__test__/userDataProcessing.test.ts | 9 ++++---- yarn.lock | 8 +++---- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 8e9cc548792..2eb32a849a1 100644 --- a/package.json +++ b/package.json @@ -170,7 +170,7 @@ "prettier": "1.14.2", "react-native-typescript-transformer": "^1.2.12", "react-test-renderer": "16.13.1", - "redux-saga-test-plan": "^3.7.0", + "redux-saga-test-plan": "4.0.0-rc.3", "rn-nodeify": "^10.0.1", "standard-version": "^8.0.2", "ts-jest": "^25.1.0", diff --git a/ts/features/bonusVacanze/store/sagas/activation/__tests__/handleBonusActivationTests.ts b/ts/features/bonusVacanze/store/sagas/activation/__tests__/handleBonusActivationTests.ts index 5a720b61a75..418365ad0db 100644 --- a/ts/features/bonusVacanze/store/sagas/activation/__tests__/handleBonusActivationTests.ts +++ b/ts/features/bonusVacanze/store/sagas/activation/__tests__/handleBonusActivationTests.ts @@ -12,6 +12,7 @@ import { completeBonusVacanzeActivation } from "../../../actions/bonusVacanze"; import { + activationSuccess, navigationActions, networkingActivationResultActions } from "../__mock__/networkingSagaResponseMockData"; @@ -33,7 +34,10 @@ type BonusVacanzeReturnType = ActionType; describe("Bonus Activation Saga, mock networking saga", () => { it("Cancel bonus activation saga", () => { - return expectSaga(handleBonusActivationSaga, mockRemote) + return expectSaga( + handleBonusActivationSaga, + mockRemote(activationSuccess.results) + ) .provide([ [ select(navigationCurrentRouteSelector), diff --git a/ts/sagas/messages/__tests__/messages.test.ts b/ts/sagas/messages/__tests__/messages.test.ts index 72eaf9b37ff..0dbc535d8a0 100644 --- a/ts/sagas/messages/__tests__/messages.test.ts +++ b/ts/sagas/messages/__tests__/messages.test.ts @@ -26,7 +26,7 @@ describe("messages", () => { describe("fetchMessage test plan", () => { it("should call getMessage with the right parameters", () => { const getMessage = jest.fn(); - testSaga(fetchMessage, getMessage, { id: testMessageId1 }) + testSaga(fetchMessage, getMessage, testMessageWithContent1) .next() .call(getMessage, { id: testMessageId1 }); }); @@ -37,7 +37,7 @@ describe("messages", () => { value: "some error occurred", context: [{ key: "", type: t.string }] }; - testSaga(fetchMessage, getMessage, { id: testMessageId1 }) + testSaga(fetchMessage, getMessage, testMessageWithContent1) .next() // Return a new `Either` holding a `Left` validatorError as getMessage response .next(left([validatorError])) @@ -47,7 +47,7 @@ describe("messages", () => { it("should only return the error if the getMessage response status is not 200", () => { const getMessage = jest.fn(); const error = Error("Backend error"); - testSaga(fetchMessage, getMessage, { id: testMessageId1 }) + testSaga(fetchMessage, getMessage, testMessageWithContent1) .next() // Return 500 with an error message as getMessage response .next(right({ status: 500, value: { title: error.message } })) @@ -56,7 +56,7 @@ describe("messages", () => { it("should return the message if the getMessage response status is 200", () => { const getMessage = jest.fn(); - testSaga(fetchMessage, getMessage, { id: testMessageId1 }) + testSaga(fetchMessage, getMessage, testMessageWithContent1) .next() // Return 200 with a valid value as getMessage response .next(right({ status: 200, value: testMessageWithContent1 })) @@ -67,7 +67,7 @@ describe("messages", () => { describe("loadMessage test plan", () => { it("should return the cached message if the message is in the cache", () => { const getMessage = jest.fn(); - testSaga(loadMessage, getMessage, { id: testMessageId1 }) + testSaga(loadMessage, getMessage, testMessageWithContent1) .next() .next({ message: pot.some(testMessageWithContent1) @@ -81,18 +81,18 @@ describe("messages", () => { it("should call fetchMessage with the right parameters", () => { const getMessage = jest.fn(); - testSaga(loadMessage, getMessage, { id: testMessageId1 }) + testSaga(loadMessage, getMessage, testMessageWithContent1) .next() .next() - .call(fetchMessage, getMessage, { id: testMessageId1 }); + .call(fetchMessage, getMessage, testMessageWithContent1); }); it("should put MESSAGE_LOAD_FAILURE and return the error if the message can't be fetched", () => { const getMessage = jest.fn(); - testSaga(loadMessage, getMessage, { id: testMessageId1 }) + testSaga(loadMessage, getMessage, testMessageWithContent1) .next() .next() - .call(fetchMessage, getMessage, { id: testMessageId1 }) + .call(fetchMessage, getMessage, testMessageWithContent1) // Return 200 with a valid message as getMessage response .next(left(Error("Error"))) .put( @@ -107,10 +107,10 @@ describe("messages", () => { it("should put MESSAGE_LOAD_SUCCESS and return the message if the message is fetched sucessfully", () => { const getMessage = jest.fn(); - testSaga(loadMessage, getMessage, { id: testMessageId1 }) + testSaga(loadMessage, getMessage, testMessageWithContent1) .next() .next() - .call(fetchMessage, getMessage, { id: testMessageId1 }) + .call(fetchMessage, getMessage, testMessageWithContent1) // Return 200 with a valid message as getMessage response .next(right(testMessageWithContent1)) .put(loadMessageAction.success(testMessageWithContent1)) diff --git a/ts/sagas/startup/__tests__/loadServiceDetailRequestHandler.test.ts b/ts/sagas/startup/__tests__/loadServiceDetailRequestHandler.test.ts index 28b90e7f80b..c4084f539a1 100644 --- a/ts/sagas/startup/__tests__/loadServiceDetailRequestHandler.test.ts +++ b/ts/sagas/startup/__tests__/loadServiceDetailRequestHandler.test.ts @@ -1,6 +1,7 @@ import { right } from "fp-ts/lib/Either"; import { OrganizationFiscalCode } from "italia-ts-commons/lib/strings"; import { testSaga } from "redux-saga-test-plan"; +import { ActionType } from "typesafe-actions"; import { DepartmentName } from "../../../../definitions/backend/DepartmentName"; import { OrganizationName } from "../../../../definitions/backend/OrganizationName"; import { ServiceId } from "../../../../definitions/backend/ServiceId"; @@ -13,9 +14,9 @@ import { loadServiceDetailRequestHandler } from "../loadServiceDetailRequestHand const mockedServiceId = "A01" as ServiceId; const getService = jest.fn(); -const mockedAction = { - type: loadServiceDetail.request, - payload: mockedServiceId +const mockedAction: ActionType = { + payload: mockedServiceId, + type: "LOAD_SERVICE_DETAIL_REQUEST" }; export const mockedService: ServicePublic = { service_id: mockedServiceId, diff --git a/ts/sagas/startup/__tests__/watchCheckSessionSaga.test.ts b/ts/sagas/startup/__tests__/watchCheckSessionSaga.test.ts index e6c58a81b91..feccded4cb2 100644 --- a/ts/sagas/startup/__tests__/watchCheckSessionSaga.test.ts +++ b/ts/sagas/startup/__tests__/watchCheckSessionSaga.test.ts @@ -79,8 +79,8 @@ describe("checkSession", () => { describe("checkSessionResult", () => { it("if session is valid do nothing", () => { - const sessionValidAction = { - type: checkCurrentSession.request, + const sessionValidAction: ReturnType = { + type: "CHECK_CURRENT_SESSION_SUCCESS", payload: { isSessionValid: true } @@ -90,8 +90,10 @@ describe("checkSessionResult", () => { .isDone(); }); it("if session is invalid call session expired", () => { - const sessionInvalidAction = { - type: checkCurrentSession.request, + const sessionInvalidAction: ReturnType< + typeof checkCurrentSession["success"] + > = { + type: "CHECK_CURRENT_SESSION_SUCCESS", payload: { isSessionValid: false } diff --git a/ts/sagas/startup/__tests__/watchLoadMessages.test.ts b/ts/sagas/startup/__tests__/watchLoadMessages.test.ts index 257b6fb55f8..36df04954e2 100644 --- a/ts/sagas/startup/__tests__/watchLoadMessages.test.ts +++ b/ts/sagas/startup/__tests__/watchLoadMessages.test.ts @@ -105,9 +105,7 @@ describe("watchLoadMessages", () => { describe("loadMessages test plan", () => { it("should put MESSAGES_LOAD_FAILURE with the Error it the getMessages response is an Error", () => { const getMessages = jest.fn(); - const getMessage = jest.fn(); - const getService = jest.fn(); - testSaga(loadMessages, getMessages, getMessage, getService) + testSaga(loadMessages, getMessages) .next() .call(getMessages, {}) // Return an error message as getMessages response @@ -120,9 +118,7 @@ describe("watchLoadMessages", () => { it("should call the getService saga N times and getMessage M times if the getMessages response contains N new services and M new messages", () => { const getMessages = jest.fn(); - const getMessage = jest.fn(); - const getService = jest.fn(); - testSaga(loadMessages, getMessages, getMessage, getService) + testSaga(loadMessages, getMessages) .next() .call(getMessages, {}) // Return 200 with a list of 2 messages as getMessages response @@ -151,9 +147,7 @@ describe("watchLoadMessages", () => { it("should not call getService and getMessage if the getMessages response contains 0 new services and 0 new messages", () => { const getMessages = jest.fn(); - const getMessage = jest.fn(); - const getService = jest.fn(); - testSaga(loadMessages, getMessages, getMessage, getService) + testSaga(loadMessages, getMessages) .next() .call(getMessages, {}) // Return 200 with a list of 2 messages as getMessages response @@ -182,9 +176,7 @@ describe("watchLoadMessages", () => { it("should remove testMessageMeta2 and not call getService and getMessage if the getMessages response contains 0 new services and 0 new messages", () => { const getMessages = jest.fn(); - const getMessage = jest.fn(); - const getService = jest.fn(); - testSaga(loadMessages, getMessages, getMessage, getService) + testSaga(loadMessages, getMessages) .next() .call(getMessages, {}) // Return 200 with a list of 2 messages as getMessages response diff --git a/ts/sagas/startup/loadServiceDetailRequestHandler.ts b/ts/sagas/startup/loadServiceDetailRequestHandler.ts index a55ccfd1305..475473c9d67 100644 --- a/ts/sagas/startup/loadServiceDetailRequestHandler.ts +++ b/ts/sagas/startup/loadServiceDetailRequestHandler.ts @@ -11,7 +11,7 @@ import { handleServiceReadabilitySaga } from "../services/handleServiceReadabili * A generator to load the service details from the Backend * * @param {function} getService - The function that makes the Backend request - * @param {string} id - The id of the service to load + * @param action * @returns {IterableIterator>} */ export function* loadServiceDetailRequestHandler( diff --git a/ts/sagas/user/__test__/userDataProcessing.test.ts b/ts/sagas/user/__test__/userDataProcessing.test.ts index 0596464f09b..81909aabf92 100644 --- a/ts/sagas/user/__test__/userDataProcessing.test.ts +++ b/ts/sagas/user/__test__/userDataProcessing.test.ts @@ -1,5 +1,6 @@ import { right } from "fp-ts/lib/Either"; import { testSaga } from "redux-saga-test-plan"; +import { ActionType } from "typesafe-actions"; import { UserDataProcessing } from "../../../../definitions/backend/UserDataProcessing"; import { UserDataProcessingChoiceEnum } from "../../../../definitions/backend/UserDataProcessingChoice"; import { UserDataProcessingStatusEnum } from "../../../../definitions/backend/UserDataProcessingStatus"; @@ -14,8 +15,8 @@ import { describe("loadUserDataProcessingSaga", () => { const getUserDataProcessingRequest = jest.fn(); - const loadAction = { - type: loadUserDataProcessing.request, + const loadAction: ActionType = { + type: "LOAD_USER_DATA_PROCESSING_REQUEST", payload: UserDataProcessingChoiceEnum.DOWNLOAD }; @@ -97,8 +98,8 @@ describe("loadUserDataProcessingSaga", () => { describe("upsertUserDataProcessingSaga", () => { const postUserDataProcessingRequest = jest.fn(); - const requestAction = { - type: loadUserDataProcessing.request, + const requestAction: ActionType = { + type: "UPSERT_USER_DATA_PROCESSING_REQUEST", payload: UserDataProcessingChoiceEnum.DOWNLOAD }; diff --git a/yarn.lock b/yarn.lock index 00a52cbbb95..5a1d3004d97 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9711,10 +9711,10 @@ redux-persist@5.10.0: resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-5.10.0.tgz#5d8d802c5571e55924efc1c3a9b23575283be62b" integrity sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg== -redux-saga-test-plan@^3.7.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/redux-saga-test-plan/-/redux-saga-test-plan-3.7.0.tgz#c8f513b1c6e13eef526a6b8a2e9076b6f26f5698" - integrity sha512-et9kCnME01kjoKXFfSk4FkozgOPPvllt9TlpL6A7ZYIS/WgoEFMLXk/UYww8KWXbmk5Qo2IF6xCc/IS1KmvP6A== +redux-saga-test-plan@4.0.0-rc.3: + version "4.0.0-rc.3" + resolved "https://registry.yarnpkg.com/redux-saga-test-plan/-/redux-saga-test-plan-4.0.0-rc.3.tgz#bde05527202be652859e68d15cdabe79ffa7509a" + integrity sha512-18Ha1AWmP4Xt64cSyJv2j7sH8lwQzdk/LByiyhoNyuqyhzkQzlKlflHr3LqiSCzn3e2AgFxagynto8XGRqsHcg== dependencies: core-js "^2.4.1" fsm-iterator "^1.1.0" From 3de8a698b0f393bf3d66ef66df2184cff40a44d2 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Wed, 12 Aug 2020 11:01:19 +0200 Subject: [PATCH 08/19] [#165057751] Migrate Typescript transpile to babel --- metro.config.js | 7 +++++- package.json | 1 - ts/__mocks__/react-native-keychain.ts | 2 +- ts/components/InstabugChatsComponent.tsx | 3 +-- ts/theme/fonts.ts | 2 +- ts/utils/keychain.ts | 2 +- tsconfig.json | 13 ++++++------ yarn.lock | 27 ++---------------------- 8 files changed, 18 insertions(+), 39 deletions(-) diff --git a/metro.config.js b/metro.config.js index 91a9ae04172..2e709bb90b1 100644 --- a/metro.config.js +++ b/metro.config.js @@ -1,5 +1,10 @@ module.exports = { transformer: { - babelTransformerPath: require.resolve('react-native-typescript-transformer') + getTransformOptions: async () => ({ + transform: { + experimentalImportSupport: false, + inlineRequires: false + } + }) } }; diff --git a/package.json b/package.json index a3d9d1a1b66..b36778488d5 100644 --- a/package.json +++ b/package.json @@ -168,7 +168,6 @@ "plist": "^3.0.1", "postinstall-postinstall": "^1.0.0", "prettier": "1.14.2", - "react-native-typescript-transformer": "^1.2.12", "react-test-renderer": "16.13.1", "redux-saga-test-plan": "4.0.0-rc.3", "rn-nodeify": "^10.0.1", diff --git a/ts/__mocks__/react-native-keychain.ts b/ts/__mocks__/react-native-keychain.ts index 0d7ae88a378..c9d39b2bece 100644 --- a/ts/__mocks__/react-native-keychain.ts +++ b/ts/__mocks__/react-native-keychain.ts @@ -2,7 +2,7 @@ * A mocked version of the Keychain */ -type KeychainDB = { +export type KeychainDB = { [key: string]: { username: string; password: string; diff --git a/ts/components/InstabugChatsComponent.tsx b/ts/components/InstabugChatsComponent.tsx index cf8c54b5f7a..c09d7786f28 100644 --- a/ts/components/InstabugChatsComponent.tsx +++ b/ts/components/InstabugChatsComponent.tsx @@ -17,7 +17,6 @@ import variables from "../theme/variables"; import ButtonDefaultOpacity from "./ButtonDefaultOpacity"; import CustomBadge from "./ui/CustomBadge"; import IconFont from "./ui/IconFont"; -import reportType = BugReporting.reportType; interface OwnProps { color?: string; @@ -79,7 +78,7 @@ class InstabugChatsComponent extends React.PureComponent { // Register to the instabug dismiss event. (https://docs.instabug.com/docs/react-native-bug-reporting-event-handlers#section-after-dismissing-instabug) // This event is fired when chat or bug screen is dismissed BugReporting.onSDKDismissedHandler( - (dismiss: dismissType, _: reportType): void => { + (dismiss: dismissType, _: BugReporting.reportType): void => { // Due an Instabug library bug, we can't use the report parameter because it always has "bug" as value. // We need to differentiate the type of report then use instabugReportType if (this.state.instabugReportType.isSome()) { diff --git a/ts/theme/fonts.ts b/ts/theme/fonts.ts index 506964d73e7..a9196e4f59b 100644 --- a/ts/theme/fonts.ts +++ b/ts/theme/fonts.ts @@ -28,7 +28,7 @@ const fontWeights = { type FontFamily = keyof typeof fonts; export type FontWeight = keyof typeof fontWeights; -const enum FontStyle { +enum FontStyle { "normal" = "normal", "italic" = "italic" } diff --git a/ts/utils/keychain.ts b/ts/utils/keychain.ts index 2c87863c2c6..a0718aba72f 100644 --- a/ts/utils/keychain.ts +++ b/ts/utils/keychain.ts @@ -22,7 +22,7 @@ const PIN_KEY = "PIN"; export async function setGenericPasswordWithDefaultAccessibleOption( username: string, password: string, - options?: Options + options?: Keychain.Options ) { return Keychain.setGenericPassword(username, password, { ...options, diff --git a/tsconfig.json b/tsconfig.json index 51c53371e80..3d897f6383d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { - "target": "es2015", - "module": "es2015", + "target": "esnext", + "module": "commonjs", + "lib": ["es6", "dom"], "jsx": "react", "noEmit": true, "moduleResolution": "node", @@ -16,14 +17,12 @@ "noUnusedParameters": true, "noUnusedLocals": true, "strictFunctionTypes": true, - "skipLibCheck": true + "skipLibCheck": true, + "isolatedModules": true }, - "lib": [ - "dom" - ], "exclude": [ "android", "ios", "node_modules" ] -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 5a1d3004d97..0dbac88b4cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3095,7 +3095,7 @@ chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.0, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -3965,7 +3965,7 @@ deepmerge@^3.2.0: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-3.3.0.tgz#d3c47fd6f3a93d517b14426b0628a17b0125f5f7" integrity sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA== -deepmerge@^4.0.0, deepmerge@^4.2.2: +deepmerge@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== @@ -4819,11 +4819,6 @@ find-cache-dir@^2.0.0: make-dir "^2.0.0" pkg-dir "^3.0.0" -find-root@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4" - integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng== - find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -6690,11 +6685,6 @@ jetifier@^1.6.2: resolved "https://registry.yarnpkg.com/jetifier/-/jetifier-1.6.6.tgz#fec8bff76121444c12dc38d2dad6767c421dab68" integrity sha512-JNAkmPeB/GS2tCRqUzRPsTOHpGDah7xP18vGJfIjZC+W2sxEHbxgJxetIjIqhjQ3yYbYNEELkM/spKLtwoOSUQ== -jju@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a" - integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo= - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -9375,19 +9365,6 @@ react-native-touch-id@^4.4.1: resolved "https://registry.yarnpkg.com/react-native-touch-id/-/react-native-touch-id-4.4.1.tgz#8b1bb2d04c30bac36bb9696d2d723e719c4a8b08" integrity sha512-1jTl8fC+0fxvqegy/XXTyo6vMvPhjzkoDdaqoYZx0OH8AT250NuXnNPyKktvigIcys3+2acciqOeaCall7lrvg== -react-native-typescript-transformer@^1.2.12: - version "1.2.13" - resolved "https://registry.yarnpkg.com/react-native-typescript-transformer/-/react-native-typescript-transformer-1.2.13.tgz#be92a3d110dbb2cf2f4aebe60a935be124cfb7ed" - integrity sha512-uLL6U9BirM+gKRZNKqJQW+m1onh+goiwDqG4+9XSy5dUhjmkjCkbx8j2eahie9hFcHJdnknJ6wRAEF5/7mGWmw== - dependencies: - babel-traverse "^6.26.0" - chalk "^2.4.0" - deepmerge "^4.0.0" - find-root "^1.1.0" - jju "^1.3.0" - semver "^5.4.1" - source-map "^0.5.6" - react-native-vector-icons@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/react-native-vector-icons/-/react-native-vector-icons-7.0.0.tgz#5b92ed363c867645daad48c559e1f99efcfbb813" From 9662a579115c69b795368a43601224aa394eccdb Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Thu, 13 Aug 2020 16:01:04 +0200 Subject: [PATCH 09/19] [#174318137] upgrade saga signature --- package.json | 2 +- .../activation/getBonusActivationSaga.ts | 12 +++++-- .../eligibility/getBonusEligibilitySaga.ts | 12 +++++-- ts/sagas/backendInfo.ts | 10 +++--- ts/sagas/backendStatus.ts | 9 ++--- ts/sagas/contentLoaders.ts | 6 +++- ts/sagas/identification.ts | 8 +++-- ts/sagas/instabug.ts | 7 ++-- ts/sagas/installation.ts | 6 ++-- ts/sagas/messages/messages.ts | 13 ++++--- ts/sagas/notifications.ts | 6 ++-- ts/sagas/preferences.ts | 11 +++--- ts/sagas/profile.ts | 23 ++++++------ ts/sagas/startup.ts | 2 +- ts/sagas/startup/authenticationSaga.ts | 10 +++--- ts/sagas/startup/checkAcceptedTosSaga.ts | 11 +++--- .../checkAcknowledgedFingerprintSaga.ts | 22 +++++++----- ts/sagas/startup/checkConfiguredPinSaga.ts | 16 ++++----- .../checkEmailNotificationPreferencesSaga.ts | 12 ++++--- ts/sagas/startup/checkProfileEnabledSaga.ts | 11 +++--- .../loadServiceDetailRequestHandler.ts | 7 ++-- .../startup/loadSessionInformationSaga.ts | 11 +++--- .../startup/loadVisibleServicesHandler.ts | 7 ++-- ts/sagas/startup/saveNavigationStateSaga.ts | 10 +++--- .../watchLoadMessageWithRelationsSaga.ts | 2 +- ts/sagas/startup/watchLoadMessagesSaga.ts | 4 +-- ts/sagas/user/userMetadata.ts | 36 +++++++++++-------- ts/sagas/wallet.ts | 6 ++-- ts/sagas/wallet/pagopaApis.ts | 18 +++++----- ts/types/utils.ts | 13 ++++--- yarn.lock | 8 ++--- 31 files changed, 189 insertions(+), 142 deletions(-) diff --git a/package.json b/package.json index c9fb3fde4ad..cdcac4f764f 100644 --- a/package.json +++ b/package.json @@ -175,7 +175,7 @@ "ts-jest": "^25.1.0", "ts-node": "^7.0.1", "tslint": "5.20.0", - "typescript": "3.4.1" + "typescript": "^3.8.3" }, "resolutions": { "@types/react": "16.7.18", diff --git a/ts/features/bonusVacanze/store/sagas/activation/getBonusActivationSaga.ts b/ts/features/bonusVacanze/store/sagas/activation/getBonusActivationSaga.ts index 29653ab2fbb..516c02c5a7c 100644 --- a/ts/features/bonusVacanze/store/sagas/activation/getBonusActivationSaga.ts +++ b/ts/features/bonusVacanze/store/sagas/activation/getBonusActivationSaga.ts @@ -36,7 +36,11 @@ function* getBonusActivation( typeof BackendBonusVacanze >["getLatestBonusVacanzeFromId"], bonusId: string -): IterableIterator, BonusActivationWithQrCode>> { +): Generator< + Effect, + Either, BonusActivationWithQrCode>, + SagaCallReturnType +> { try { const getLatestBonusVacanzeFromIdResult: SagaCallReturnType< typeof getLatestBonusVacanzeFromId @@ -87,8 +91,10 @@ export const bonusActivationSaga = ( typeof BackendBonusVacanze >["getLatestBonusVacanzeFromId"] ) => - function* startBonusActivationSaga(): IterableIterator< - Effect | ActionType + function* startBonusActivationSaga(): Generator< + Effect, + ActionType, + any > { try { const startBonusActivationProcedureResult: SagaCallReturnType< diff --git a/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts b/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts index 331bb0db573..b7250e0bf1b 100644 --- a/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts +++ b/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts @@ -58,7 +58,11 @@ function* getCheckBonusEligibilitySaga( getBonusEligibilityCheck: ReturnType< typeof BackendBonusVacanze >["getBonusEligibilityCheck"] -): IterableIterator, EligibilityCheck>> { +): Generator< + Effect, + Either, EligibilityCheck>, + SagaCallReturnType +> { try { const eligibilityCheckResult: SagaCallReturnType< typeof getBonusEligibilityCheck @@ -105,8 +109,10 @@ export const bonusEligibilitySaga = ( typeof BackendBonusVacanze >["getBonusEligibilityCheck"] ) => - function* getBonusEligibilitySaga(): IterableIterator< - Effect | ActionType + function* getBonusEligibilitySaga(): Generator< + Effect, + ActionType, + any > { try { const startEligibilityResult: SagaCallReturnType< diff --git a/ts/sagas/backendInfo.ts b/ts/sagas/backendInfo.ts index 59169ab4e88..861374bcfcf 100644 --- a/ts/sagas/backendInfo.ts +++ b/ts/sagas/backendInfo.ts @@ -21,7 +21,11 @@ const BACKEND_INFO_LOAD_INTERVAL = 60 * 60 * 1000; // retry loading backend info every 10 seconds on error const BACKEND_INFO_RETRY_INTERVAL = 10 * 1000; -function* backendInfoWatcher(): IterableIterator { +function* backendInfoWatcher(): Generator< + Effect, + void, + SagaCallReturnType +> { const backendPublicClient = BackendPublicClient(apiUrlPrefix); function getServerInfo(): Promise< @@ -36,9 +40,7 @@ function* backendInfoWatcher(): IterableIterator { while (true) { try { - const backendInfoResponse: SagaCallReturnType< - typeof getServerInfo - > = yield call(getServerInfo); + const backendInfoResponse = yield call(getServerInfo); if ( backendInfoResponse.isRight() && backendInfoResponse.value.status === 200 diff --git a/ts/sagas/backendStatus.ts b/ts/sagas/backendStatus.ts index 5cd784ebd8f..6cad9269476 100644 --- a/ts/sagas/backendStatus.ts +++ b/ts/sagas/backendStatus.ts @@ -16,12 +16,9 @@ const BACKEND_SERVICES_STATUS_FAILURE_INTERVAL = (10 * 1000) as Millisecond; // Return true if it has information (200) false otherwise export function* backendStatusSaga( getServicesStatus: ReturnType["getStatus"] -): IterableIterator { +): Generator> { try { - const response: SagaCallReturnType = yield call( - getServicesStatus, - {} - ); + const response = yield call(getServicesStatus, {}); if (response.isRight() && response.value.status === 200) { yield put(backendStatusLoadSuccess(response.value.value)); return true; @@ -40,7 +37,7 @@ export function* backendStatusSaga( */ export function* backendStatusWatcherLoop( getStatus: ReturnType["getStatus"] -): IterableIterator { +) { // check backend status periodically while (true) { const response: SagaCallReturnType = yield call( diff --git a/ts/sagas/contentLoaders.ts b/ts/sagas/contentLoaders.ts index 58f44b833f7..1854ea69754 100644 --- a/ts/sagas/contentLoaders.ts +++ b/ts/sagas/contentLoaders.ts @@ -140,7 +140,11 @@ function* watchServiceMetadataLoadSaga( function* fetchMunicipalityMetadata( getMunicipality: ReturnType["getMunicipality"], codiceCatastale: CodiceCatastale -): IterableIterator> { +): Generator< + Effect, + Either, + SagaCallReturnType +> { try { const response: SagaCallReturnType = yield call( getMunicipality, diff --git a/ts/sagas/identification.ts b/ts/sagas/identification.ts index 4e868528f1b..e9a14c2f581 100644 --- a/ts/sagas/identification.ts +++ b/ts/sagas/identification.ts @@ -47,7 +47,11 @@ type ResultAction = | ActionType | ActionType; // Wait the identification and return the result -function* waitIdentificationResult(): Iterator { +function* waitIdentificationResult(): Generator< + Effect, + void | IdentificationResult, + any +> { const resultAction: ResultAction = yield take([ getType(identificationCancel), getType(identificationPinReset), @@ -136,7 +140,7 @@ export function* startAndReturnIdentificationResult( function* startAndHandleIdentificationResult( pin: PinString, identificationRequestAction: ActionType -): IterableIterator { +) { yield put( identificationStart( pin, diff --git a/ts/sagas/instabug.ts b/ts/sagas/instabug.ts index 4fb5e5f30a0..34144627429 100644 --- a/ts/sagas/instabug.ts +++ b/ts/sagas/instabug.ts @@ -4,7 +4,6 @@ import { instabugUnreadMessagesLoaded, updateInstabugUnreadMessages } from "../store/actions/instabug"; -import { SagaCallReturnType } from "../types/utils"; const loadInstabugUnreadMessages = () => { return new Promise(resolve => { @@ -31,10 +30,8 @@ function* watchInstabugSaga(): IterableIterator { } } -function* updateInstabugBadgeSaga(): IterableIterator { - const repliesCount: SagaCallReturnType< - typeof loadInstabugUnreadMessages - > = yield call(loadInstabugUnreadMessages); +function* updateInstabugBadgeSaga(): Generator { + const repliesCount = yield call(loadInstabugUnreadMessages); yield put(instabugUnreadMessagesLoaded(repliesCount)); } diff --git a/ts/sagas/installation.ts b/ts/sagas/installation.ts index ecf9911d54c..8e453eedca2 100644 --- a/ts/sagas/installation.ts +++ b/ts/sagas/installation.ts @@ -12,8 +12,10 @@ import { deletePin } from "../utils/keychain"; * This generator function removes user data from previous application * installation */ -export function* previousInstallationDataDeleteSaga(): IterableIterator< - Effect +export function* previousInstallationDataDeleteSaga(): Generator< + Effect, + void, + boolean > { const isFirstRunAfterInstall: ReturnType< typeof isFirstRunAfterInstallSelector diff --git a/ts/sagas/messages/messages.ts b/ts/sagas/messages/messages.ts index 9d498f4953d..3dd1f2ef35a 100644 --- a/ts/sagas/messages/messages.ts +++ b/ts/sagas/messages/messages.ts @@ -17,11 +17,14 @@ import { readablePrivacyReport } from "../../utils/reporters"; /** * A saga to fetch a message from the Backend and save it in the redux store. */ + export function* loadMessage( getMessage: ReturnType["getMessage"], meta: CreatedMessageWithoutContent -): IterableIterator< - Effect | Either +): Generator< + Effect, + Either, + any > { // Load the messages already in the redux store const cachedMessage: ReturnType< @@ -63,8 +66,10 @@ export function* loadMessage( export function* fetchMessage( getMessage: ReturnType["getMessage"], meta: CreatedMessageWithoutContent -): IterableIterator< - Effect | Either +): Generator< + Effect, + Either, + any > { try { const response: SagaCallReturnType = yield call( diff --git a/ts/sagas/notifications.ts b/ts/sagas/notifications.ts index 87c5b1f6815..5d53f164db8 100644 --- a/ts/sagas/notifications.ts +++ b/ts/sagas/notifications.ts @@ -25,8 +25,10 @@ export function* updateInstallationSaga( createOrUpdateInstallation: ReturnType< typeof BackendClient >["createOrUpdateInstallation"] -): Iterator< - Effect | TypeOfApiResponseStatus | undefined +): Generator< + Effect, + TypeOfApiResponseStatus | undefined, + any > { // Get the notifications installation data from the store const notificationsInstallation: ReturnType< diff --git a/ts/sagas/preferences.ts b/ts/sagas/preferences.ts index f4a51b24385..b12a4fc8d15 100644 --- a/ts/sagas/preferences.ts +++ b/ts/sagas/preferences.ts @@ -8,10 +8,11 @@ import { SagaCallReturnType } from "../types/utils"; /** * A saga that retrieves the system languages */ -export function* loadSystemPreferencesSaga(): IterableIterator { - const languages: SagaCallReturnType = yield call( - getLanguages - ); - +export function* loadSystemPreferencesSaga(): Generator< + Effect, + void, + SagaCallReturnType +> { + const languages = yield call(getLanguages); yield put(preferencesLanguagesLoadSuccess(languages)); } diff --git a/ts/sagas/profile.ts b/ts/sagas/profile.ts index 5c5fbbe1cdb..49ca1a5a940 100644 --- a/ts/sagas/profile.ts +++ b/ts/sagas/profile.ts @@ -25,12 +25,13 @@ import { SagaCallReturnType } from "../types/utils"; // A saga to load the Profile. export function* loadProfile( getProfile: ReturnType["getProfile"] -): Iterator> { +): Generator< + Effect, + Option, + SagaCallReturnType +> { try { - const response: SagaCallReturnType = yield call( - getProfile, - {} - ); + const response = yield call(getProfile, {}); // we got an error, throw it if (response.isLeft()) { throw Error(readableReport(response.value)); @@ -63,7 +64,7 @@ function* createOrUpdateProfileSaga( typeof BackendClient >["createOrUpdateProfile"], action: ActionType -): Iterator { +): Generator { // Get the current Profile from the state const profileState: ReturnType = yield select( profileSelector @@ -166,11 +167,13 @@ export function* startEmailValidationProcessSaga( startEmailValidationProcess: ReturnType< typeof BackendClient >["startEmailValidationProcess"] -): Iterator> { +): Generator< + Effect, + Option, + SagaCallReturnType +> { try { - const response: SagaCallReturnType< - typeof startEmailValidationProcess - > = yield call(startEmailValidationProcess, {}); + const response = yield call(startEmailValidationProcess, {}); // we got an error, throw it if (response.isLeft()) { throw Error(readableReport(response.value)); diff --git a/ts/sagas/startup.ts b/ts/sagas/startup.ts index b02ea05e119..64456fd48d0 100644 --- a/ts/sagas/startup.ts +++ b/ts/sagas/startup.ts @@ -96,7 +96,7 @@ const WAIT_INITIALIZE_SAGA = 3000 as Millisecond; * Handles the application startup and the main application logic loop */ // tslint:disable-next-line:cognitive-complexity no-big-function -export function* initializeApplicationSaga(): IterableIterator { +export function* initializeApplicationSaga(): Generator { // Remove explicitly previous session data. This is done as completion of two // use cases: // 1. Logout with data reset diff --git a/ts/sagas/startup/authenticationSaga.ts b/ts/sagas/startup/authenticationSaga.ts index 3acb958b9df..b945653d5d6 100644 --- a/ts/sagas/startup/authenticationSaga.ts +++ b/ts/sagas/startup/authenticationSaga.ts @@ -14,7 +14,11 @@ import { stopCieManager, watchCieAuthenticationSaga } from "../cie"; * A saga that makes the user go through the authentication process until * a SessionToken gets produced. */ -export function* authenticationSaga(): IterableIterator { +export function* authenticationSaga(): Generator< + Effect, + SessionToken, + ActionType +> { yield put(analyticsAuthenticationStarted()); // Watch for login by CIE @@ -25,9 +29,7 @@ export function* authenticationSaga(): IterableIterator { // Wait until the user has successfully logged in with SPID // FIXME: show an error on LOGIN_FAILED? - const action: ActionType = yield take( - getType(loginSuccess) - ); + const action = yield take(getType(loginSuccess)); yield cancel(watchCieAuthentication); // stop cie manager from listening nfc diff --git a/ts/sagas/startup/checkAcceptedTosSaga.ts b/ts/sagas/startup/checkAcceptedTosSaga.ts index b66b0e804a4..e88f880891f 100644 --- a/ts/sagas/startup/checkAcceptedTosSaga.ts +++ b/ts/sagas/startup/checkAcceptedTosSaga.ts @@ -9,7 +9,12 @@ import { isProfileFirstOnBoarding } from "../../store/reducers/profile"; export function* checkAcceptedTosSaga( userProfile: InitializedProfile -): IterableIterator { +): Generator< + Effect, + void, + | ActionType + | ActionType +> { // The user has to explicitly accept the new version of ToS if: // - this is the first access // - the user profile stores the user accepted an old version of ToS @@ -37,9 +42,7 @@ export function* checkAcceptedTosSaga( */ if (userProfile.has_profile) { yield put(profileUpsert.request({ accepted_tos_version: tosVersion })); - const action: - | ActionType - | ActionType = yield take([ + const action = yield take([ getType(profileUpsert.success), getType(profileUpsert.failure) ]); diff --git a/ts/sagas/startup/checkAcknowledgedFingerprintSaga.ts b/ts/sagas/startup/checkAcknowledgedFingerprintSaga.ts index 453d86a7b29..980bd1d22ba 100644 --- a/ts/sagas/startup/checkAcknowledgedFingerprintSaga.ts +++ b/ts/sagas/startup/checkAcknowledgedFingerprintSaga.ts @@ -20,12 +20,14 @@ export type BiometrySimpleType = * All other cases are treated as a single umbrella case "Unavailable: Not * supported/Others". */ -function* onboardFingerprintIfAvailableSaga(): IterableIterator { +function* onboardFingerprintIfAvailableSaga(): Generator< + Effect, + void, + BiometrySimpleType +> { // Check if user device has biometric recognition feature by trying to // query data from TouchID library - const biometryTypeOrUnsupportedReason: BiometrySimpleType = yield call( - getFingerprintSettings - ); + const biometryTypeOrUnsupportedReason = yield call(getFingerprintSettings); if (biometryTypeOrUnsupportedReason !== "UNAVAILABLE") { // If biometric recognition is available, navigate to the Fingerprint @@ -67,12 +69,16 @@ function* onboardFingerprintIfAvailableSaga(): IterableIterator { * saga that prompts it, otherwise. Consider that, like ToS, this should happen * at first launch of the app ONLY. */ -export function* checkAcknowledgedFingerprintSaga(): IterableIterator { +export function* checkAcknowledgedFingerprintSaga(): Generator< + Effect, + void, + ReturnType +> { // Query system state and check whether the user has already acknowledged biometric // recognition Screen. Consider that, like ToS, this should be displayed once. - const isFingerprintAcknowledged: ReturnType< - typeof isFingerprintAcknowledgedSelector - > = yield select(isFingerprintAcknowledgedSelector); + const isFingerprintAcknowledged = yield select( + isFingerprintAcknowledgedSelector + ); if (!isFingerprintAcknowledged) { // Navigate to the FingerprintScreen and wait for acknowledgment diff --git a/ts/sagas/startup/checkConfiguredPinSaga.ts b/ts/sagas/startup/checkConfiguredPinSaga.ts index 4f9a9b56cd5..50eb099aca2 100644 --- a/ts/sagas/startup/checkConfiguredPinSaga.ts +++ b/ts/sagas/startup/checkConfiguredPinSaga.ts @@ -1,21 +1,17 @@ -import { Option } from "fp-ts/lib/Option"; -import { Effect } from "redux-saga/effects"; -import { call, put, take } from "redux-saga/effects"; +import { call, Effect, put, take } from "redux-saga/effects"; import { ActionType, getType } from "typesafe-actions"; -import { getPin } from "../../utils/keychain"; +import { navigateToOnboardingPinScreenAction } from "../../store/actions/navigation"; +import { createPinSuccess } from "../../store/actions/pinset"; import { PinString } from "../../types/PinString"; -import { navigateToOnboardingPinScreenAction } from "../../store/actions/navigation"; -import { createPinSuccess } from "../../store/actions/pinset"; +import { getPin } from "../../utils/keychain"; -export function* checkConfiguredPinSaga(): IterableIterator< - Effect | PinString -> { +export function* checkConfiguredPinSaga(): Generator { // We check whether the user has already created a unlock code by trying to retrieve // it from the Keychain - const pinCode: Option = yield call(getPin); + const pinCode = yield call(getPin); if (pinCode.isSome()) { return pinCode.value; diff --git a/ts/sagas/startup/checkEmailNotificationPreferencesSaga.ts b/ts/sagas/startup/checkEmailNotificationPreferencesSaga.ts index 6f73cdda807..a81f14a5f07 100644 --- a/ts/sagas/startup/checkEmailNotificationPreferencesSaga.ts +++ b/ts/sagas/startup/checkEmailNotificationPreferencesSaga.ts @@ -26,12 +26,14 @@ import { profileSelector, ProfileState } from "../../store/reducers/profile"; * A saga to match at the first startup if the user has customized settings related to the * forwarding of notifications on the verified email within previous installations */ -export function* watchEmailNotificationPreferencesSaga(): IterableIterator< - Effect +export function* watchEmailNotificationPreferencesSaga(): Generator< + Effect, + void, + ReturnType > { - const isCustomEmailChannelEnabled: ReturnType< - typeof isCustomEmailChannelEnabledSelector - > = yield select(isCustomEmailChannelEnabledSelector); + const isCustomEmailChannelEnabled = yield select( + isCustomEmailChannelEnabledSelector + ); // if we know about user choice do nothing if (pot.isSome(isCustomEmailChannelEnabled)) { diff --git a/ts/sagas/startup/checkProfileEnabledSaga.ts b/ts/sagas/startup/checkProfileEnabledSaga.ts index 210ef65f776..b881c5a0680 100644 --- a/ts/sagas/startup/checkProfileEnabledSaga.ts +++ b/ts/sagas/startup/checkProfileEnabledSaga.ts @@ -12,7 +12,12 @@ import { export function* checkProfileEnabledSaga( profile: InitializedProfile -): IterableIterator { +): Generator< + Effect, + void, + | ActionType + | ActionType +> { if ( isProfileFirstOnBoarding(profile) && (!hasProfileEmail(profile) || @@ -26,9 +31,7 @@ export function* checkProfileEnabledSaga( is_webhook_enabled: true }) ); - const action: - | ActionType - | ActionType = yield take([ + const action = yield take([ getType(profileUpsert.success), getType(profileUpsert.failure) ]); diff --git a/ts/sagas/startup/loadServiceDetailRequestHandler.ts b/ts/sagas/startup/loadServiceDetailRequestHandler.ts index 475473c9d67..49f92b21a84 100644 --- a/ts/sagas/startup/loadServiceDetailRequestHandler.ts +++ b/ts/sagas/startup/loadServiceDetailRequestHandler.ts @@ -17,12 +17,9 @@ import { handleServiceReadabilitySaga } from "../services/handleServiceReadabili export function* loadServiceDetailRequestHandler( getService: ReturnType["getService"], action: ActionType -): IterableIterator { +): Generator> { try { - const response: SagaCallReturnType = yield call( - getService, - { service_id: action.payload } - ); + const response = yield call(getService, { service_id: action.payload }); if (response.isLeft()) { throw Error(readableReport(response.value)); diff --git a/ts/sagas/startup/loadSessionInformationSaga.ts b/ts/sagas/startup/loadSessionInformationSaga.ts index b433648d4f6..31e8f624363 100644 --- a/ts/sagas/startup/loadSessionInformationSaga.ts +++ b/ts/sagas/startup/loadSessionInformationSaga.ts @@ -22,13 +22,14 @@ import { SagaCallReturnType } from "../../types/utils"; */ export function* loadSessionInformationSaga( getSession: ReturnType["getSession"] -): IterableIterator> { +): Generator< + Effect, + Option, + SagaCallReturnType +> { try { // Call the Backend service - const response: SagaCallReturnType = yield call( - getSession, - {} - ); + const response = yield call(getSession, {}); // Ko we got an error if (response.isLeft()) { throw readableReport(response.value); diff --git a/ts/sagas/startup/loadVisibleServicesHandler.ts b/ts/sagas/startup/loadVisibleServicesHandler.ts index 5ccc1858fff..e29932f992b 100644 --- a/ts/sagas/startup/loadVisibleServicesHandler.ts +++ b/ts/sagas/startup/loadVisibleServicesHandler.ts @@ -16,12 +16,9 @@ import { removeUnusedStoredServices } from "../services/removeUnusedStoredServic */ export function* loadVisibleServicesRequestHandler( getVisibleServices: ReturnType["getVisibleServices"] -): IterableIterator { +): Generator> { try { - const response: SagaCallReturnType = yield call( - getVisibleServices, - {} - ); + const response = yield call(getVisibleServices, {}); if (response.isLeft()) { throw Error(readableReport(response.value)); } diff --git a/ts/sagas/startup/saveNavigationStateSaga.ts b/ts/sagas/startup/saveNavigationStateSaga.ts index 16071b2c475..a2f8832a1df 100644 --- a/ts/sagas/startup/saveNavigationStateSaga.ts +++ b/ts/sagas/startup/saveNavigationStateSaga.ts @@ -12,10 +12,12 @@ import { navigationStateSelector } from "../../store/reducers/navigation"; * navigation route. * Saving and restoring routes relies on the deep link mechanism. */ -export function* saveNavigationStateSaga(): IterableIterator { - const navigationState: ReturnType< - typeof navigationStateSelector - > = yield select(navigationStateSelector); +export function* saveNavigationStateSaga(): Generator< + Effect, + void, + ReturnType +> { + const navigationState = yield select(navigationStateSelector); const currentRoute = navigationState.routes[ navigationState.index ] as NavigationStateRoute; diff --git a/ts/sagas/startup/watchLoadMessageWithRelationsSaga.ts b/ts/sagas/startup/watchLoadMessageWithRelationsSaga.ts index eef2c6341bf..fa0e546e7f0 100644 --- a/ts/sagas/startup/watchLoadMessageWithRelationsSaga.ts +++ b/ts/sagas/startup/watchLoadMessageWithRelationsSaga.ts @@ -16,7 +16,7 @@ export function* loadMessageWithRelationsSaga( messageWithRelationsLoadRequest: ActionType< typeof loadMessageWithRelations["request"] > -): IterableIterator { +): Generator { // Extract the message id from the action payload const messageId = messageWithRelationsLoadRequest.payload; diff --git a/ts/sagas/startup/watchLoadMessagesSaga.ts b/ts/sagas/startup/watchLoadMessagesSaga.ts index 554e456aaa8..7d8eb704a3a 100644 --- a/ts/sagas/startup/watchLoadMessagesSaga.ts +++ b/ts/sagas/startup/watchLoadMessagesSaga.ts @@ -44,7 +44,7 @@ import { uniqueItem } from "../../utils/enumerables"; // tslint:disable-next-line: cognitive-complexity export function* loadMessages( getMessages: ReturnType["getMessages"] -): IterableIterator { +): Generator { // We are using try...finally to manage task cancellation // @https://redux-saga.js.org/docs/advanced/TaskCancellation.html try { @@ -184,7 +184,7 @@ export function* loadMessages( */ export function* watchMessagesLoadOrCancelSaga( getMessages: ReturnType["getMessages"] -): IterableIterator { +): Generator { // We store the latest task so we can also cancel it // tslint:disable-next-line:no-let let lastTask: Option = none; diff --git a/ts/sagas/user/userMetadata.ts b/ts/sagas/user/userMetadata.ts index 8f8e4ca921f..112578aad80 100644 --- a/ts/sagas/user/userMetadata.ts +++ b/ts/sagas/user/userMetadata.ts @@ -33,12 +33,13 @@ import { SagaCallReturnType } from "../../types/utils"; */ export function* fetchUserMetadata( getUserMetadata: ReturnType["getUserMetadata"] -): IterableIterator> { +): Generator< + Effect, + Either, + SagaCallReturnType +> { try { - const response: SagaCallReturnType = yield call( - getUserMetadata, - {} - ); + const response = yield call(getUserMetadata, {}); // Can't decode response if (response.isLeft()) { @@ -70,14 +71,19 @@ export function* fetchUserMetadata( export function* loadUserMetadata( getUserMetadata: ReturnType["getUserMetadata"], setLoading: boolean = false -): IterableIterator> { +): Generator< + Effect, + Option, + SagaCallReturnType +> { if (setLoading) { yield put(userMetadataLoad.request()); } - const backendUserMetadataOrError: SagaCallReturnType< - typeof fetchUserMetadata - > = yield call(fetchUserMetadata, getUserMetadata); + const backendUserMetadataOrError = yield call( + fetchUserMetadata, + getUserMetadata + ); if (backendUserMetadataOrError.isLeft()) { yield put(userMetadataLoad.failure(backendUserMetadataOrError.value)); @@ -130,11 +136,13 @@ export function* postUserMetadata( typeof BackendClient >["createOrUpdateUserMetadata"], backendUserMetadata: BackendUserMetadata -): IterableIterator> { +): Generator< + Effect, + Either, + SagaCallReturnType +> { try { - const response: SagaCallReturnType< - typeof createOrUpdateUserMetadata - > = yield call(createOrUpdateUserMetadata, { + const response = yield call(createOrUpdateUserMetadata, { userMetadata: backendUserMetadata }); @@ -166,7 +174,7 @@ export function* upsertUserMetadata( >["createOrUpdateUserMetadata"], userMetadata: UserMetadata, setLoading: boolean = false -): IterableIterator> { +): Generator, any> { if (setLoading) { yield put(userMetadataUpsert.request(userMetadata)); } diff --git a/ts/sagas/wallet.ts b/ts/sagas/wallet.ts index 1795c9df50c..5c34104bb89 100644 --- a/ts/sagas/wallet.ts +++ b/ts/sagas/wallet.ts @@ -484,7 +484,7 @@ export function* watchWalletSaga( sessionToken: SessionToken, walletToken: string, paymentManagerUrlPrefix: string -): Iterator { +): Generator { // Builds a backend client specifically for the pagopa-proxy endpoints that // need a fetch instance that doesn't retry requests and have longer timeout const pagopaNodoClient = BackendClient( @@ -526,9 +526,7 @@ export function* watchWalletSaga( const pmSessionManager = new SessionManager(getPaymentManagerSession); // check if the current profile (this saga starts only when the user is logged in) // has an email address validated - const isEmailValidated: ReturnType< - typeof isProfileEmailValidatedSelector - > = yield select(isProfileEmailValidatedSelector); + const isEmailValidated = yield select(isProfileEmailValidatedSelector); yield call(pmSessionManager.setSessionEnabled, isEmailValidated); // // Sagas diff --git a/ts/sagas/wallet/pagopaApis.ts b/ts/sagas/wallet/pagopaApis.ts index e5345657421..3833d546a7b 100644 --- a/ts/sagas/wallet/pagopaApis.ts +++ b/ts/sagas/wallet/pagopaApis.ts @@ -63,7 +63,7 @@ function* checkSession(): IterableIterator { export function* fetchWalletsRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager -): Iterator { +): Generator { yield call(checkSession); const request = pmSessionManager.withRefresh(pagoPaClient.getWallets); try { @@ -89,7 +89,7 @@ export function* fetchTransactionsRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager, action: ActionType -): Iterator { +): Generator { yield call(checkSession); const request = pmSessionManager.withRefresh( pagoPaClient.getTransactions(action.payload.start) @@ -122,7 +122,7 @@ export function* fetchTransactionRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager, action: ActionType -): Iterator { +): Generator { const request = pmSessionManager.withRefresh( pagoPaClient.getTransaction(action.payload) ); @@ -149,7 +149,7 @@ export function* fetchPspRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager, action: ActionType -): Iterator { +): Generator { const request = pmSessionManager.withRefresh( pagoPaClient.getPsp(action.payload.idPsp) ); @@ -192,7 +192,7 @@ export function* setFavouriteWalletRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager, action: ActionType -): Iterator { +): Generator { const favouriteWalletId = action.payload; if (favouriteWalletId === undefined) { // FIXME: currently there is no way to unset a favourite wallet @@ -306,7 +306,7 @@ export function* deleteWalletRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager, action: ActionType -): Iterator { +): Generator { const deleteWalletApi = pagoPaClient.deleteWallet(action.payload.walletId); const deleteWalletWithRefresh = pmSessionManager.withRefresh(deleteWalletApi); @@ -508,7 +508,7 @@ export function* paymentCheckRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager, action: ActionType -): Iterator { +): Generator { // FIXME: we should not use default pagopa client for checkpayment, need to // a client that doesn't retry on failure!!! checkpayment is NOT // idempotent, the 2nd time it will error! @@ -545,7 +545,7 @@ export function* paymentExecutePaymentRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager, action: ActionType -): Iterator { +): Generator { const apiPostPayment = pagoPaClient.postPayment(action.payload.idPayment, { data: { tipo: "web", idWallet: action.payload.wallet.idWallet } }); @@ -581,7 +581,7 @@ export function* paymentDeletePaymentRequestHandler( pagoPaClient: PaymentManagerClient, pmSessionManager: SessionManager, action: ActionType -): Iterator { +): Generator { const apiPostPayment = pagoPaClient.deletePayment(action.payload.paymentId); const request = pmSessionManager.withRefresh(apiPostPayment); try { diff --git a/ts/types/utils.ts b/ts/types/utils.ts index 122c0d64a03..1ad385a8006 100644 --- a/ts/types/utils.ts +++ b/ts/types/utils.ts @@ -3,15 +3,18 @@ import { Pot } from "italia-ts-commons/lib/pot"; import { Effect } from "redux-saga/effects"; import { PayloadAC, PayloadMetaAC } from "typesafe-actions/dist/type-helpers"; +import { loadMessage } from "../sagas/messages/messages"; export type SagaCallReturnType< T extends (...args: any[]) => any, R = ReturnType -> = R extends Iterator - ? B - : R extends IterableIterator - ? B1 - : R extends Promise ? B2 : never; +> = R extends Generator + ? B0 + : R extends Iterator + ? B + : R extends IterableIterator + ? B1 + : R extends Promise ? B2 : never; /** * Extracts the type of the payload of a typesafe action diff --git a/yarn.lock b/yarn.lock index 0dbac88b4cf..3be2035b28d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11371,10 +11371,10 @@ typescript-tuple@^2.2.1: dependencies: typescript-compare "^0.0.2" -typescript@3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.1.tgz#b6691be11a881ffa9a05765a205cb7383f3b63c6" - integrity sha512-3NSMb2VzDQm8oBTLH6Nj55VVtUEpe/rgkIzMir0qVoLyjDZlnMBva0U6vDiV3IH+sl/Yu6oP5QwsAQtHPmDd2Q== +typescript@^3.8.3: + version "3.9.7" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" + integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== typestrict@^1.0.2: version "1.0.2" From 5d970752e7336ba78751ad02ab6384f5249aae3c Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Thu, 13 Aug 2020 21:33:47 +0200 Subject: [PATCH 10/19] fix types for react-native-text--input-mask --- ...s+react-native-text-input-mask+0.7.2.patch | 23 +++++++++++++++++++ patches/patches.md | 7 ++++++ ts/screens/wallet/AddCardScreen.tsx | 8 +++---- ts/types/utils.ts | 1 - 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 patches/@types+react-native-text-input-mask+0.7.2.patch diff --git a/patches/@types+react-native-text-input-mask+0.7.2.patch b/patches/@types+react-native-text-input-mask+0.7.2.patch new file mode 100644 index 00000000000..d2928d810f3 --- /dev/null +++ b/patches/@types+react-native-text-input-mask+0.7.2.patch @@ -0,0 +1,23 @@ +diff --git a/node_modules/@types/react-native-text-input-mask/index.d.ts b/node_modules/@types/react-native-text-input-mask/index.d.ts +index 4cf4b39..8eacdbc 100644 +--- a/node_modules/@types/react-native-text-input-mask/index.d.ts ++++ b/node_modules/@types/react-native-text-input-mask/index.d.ts +@@ -4,6 +4,7 @@ + // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + // TypeScript Version: 2.8 + ++import {MutableRefObject} from "react"; + import * as React from "react"; + import * as ReactNative from "react-native"; + +@@ -221,6 +222,10 @@ export interface TextInputMaskProps extends ReactNative.ViewProps, ReactNative.T + * or set/update maxLength to prevent unwanted edits without flicker. + */ + value?: string; ++ ++ // Patch: Adding missing types ref and isNumericSecureKeyboard ++ ref?: ((instance: TextInputMask | null) => void) | MutableRefObject | null; ++ isNumericSecureKeyboard?: boolean, + } + + export default class TextInputMask extends React.Component { } diff --git a/patches/patches.md b/patches/patches.md index c81551db0c8..bc3116df7d1 100644 --- a/patches/patches.md +++ b/patches/patches.md @@ -68,3 +68,10 @@ Created on **12/08/2020** #### Reason: - Use TouchableHighlight instead of TouchableNativeFeedback on Android sdk < 19 to avoid crash. + + +### @types/react-native-text-input-mask+0.7.2 +Created on **13/08/2020** + +#### Reason: +- Add missing props types for TextInputMaskProps. diff --git a/ts/screens/wallet/AddCardScreen.tsx b/ts/screens/wallet/AddCardScreen.tsx index 33417f340f3..5bae969e091 100644 --- a/ts/screens/wallet/AddCardScreen.tsx +++ b/ts/screens/wallet/AddCardScreen.tsx @@ -9,6 +9,7 @@ import { Content, Item, Text, View } from "native-base"; import * as React from "react"; import { FlatList, Image, ScrollView, StyleSheet } from "react-native"; import { Col, Grid } from "react-native-easy-grid"; +import TextInputMask from "react-native-text-input-mask"; import { NavigationInjectedProps } from "react-navigation"; import { connect } from "react-redux"; import { PaymentRequestsGetResponse } from "../../../definitions/backend/PaymentRequestsGetResponse"; @@ -17,7 +18,6 @@ import BaseScreenComponent, { ContextualHelpPropsMarkdown } from "../../components/screens/BaseScreenComponent"; import FooterWithButtons from "../../components/ui/FooterWithButtons"; -import MaskedInput from "../../components/ui/MaskedInput"; import { cardIcons } from "../../components/wallet/card/Logo"; import I18n from "../../i18n"; import { navigateToWalletConfirmCardDetails } from "../../store/actions/navigation"; @@ -147,9 +147,9 @@ const displayedCards: { [key: string]: any } = { }; class AddCardScreen extends React.Component { - private panRef = React.createRef(); - private expirationDateRef = React.createRef(); - private securityCodeRef = React.createRef(); + private panRef = React.createRef(); + private expirationDateRef = React.createRef(); + private securityCodeRef = React.createRef(); constructor(props: Props) { super(props); diff --git a/ts/types/utils.ts b/ts/types/utils.ts index 1ad385a8006..94245122a5a 100644 --- a/ts/types/utils.ts +++ b/ts/types/utils.ts @@ -3,7 +3,6 @@ import { Pot } from "italia-ts-commons/lib/pot"; import { Effect } from "redux-saga/effects"; import { PayloadAC, PayloadMetaAC } from "typesafe-actions/dist/type-helpers"; -import { loadMessage } from "../sagas/messages/messages"; export type SagaCallReturnType< T extends (...args: any[]) => any, From b455131fe5d19fe15623ba0dce3df1e5eebe1b02 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 10:29:45 +0200 Subject: [PATCH 11/19] fix left and right --- .../activation/getBonusActivationSaga.ts | 20 ++++++++++++------- .../eligibility/getBonusEligibilitySaga.ts | 8 ++++---- ts/sagas/contentLoaders.ts | 4 ++-- ts/sagas/messages/messages.ts | 6 +++--- ts/sagas/user/userMetadata.ts | 14 ++++++------- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/ts/features/bonusVacanze/store/sagas/activation/getBonusActivationSaga.ts b/ts/features/bonusVacanze/store/sagas/activation/getBonusActivationSaga.ts index 516c02c5a7c..da4127bd0ee 100644 --- a/ts/features/bonusVacanze/store/sagas/activation/getBonusActivationSaga.ts +++ b/ts/features/bonusVacanze/store/sagas/activation/getBonusActivationSaga.ts @@ -53,24 +53,30 @@ function* getBonusActivation( switch (activation.status) { // processing -> polling should continue case BonusActivationStatusEnum.PROCESSING: - return left(none); + return left, BonusActivationWithQrCode>(none); case BonusActivationStatusEnum.FAILED: // blocking error - return left(some(new Error("Bonus Activation failed"))); + return left, BonusActivationWithQrCode>( + some(new Error("Bonus Activation failed")) + ); default: // active - return right(getLatestBonusVacanzeFromIdResult.value.value); + return right, BonusActivationWithQrCode>( + getLatestBonusVacanzeFromIdResult.value.value + ); } } // Request not found - polling must be stopped if (getLatestBonusVacanzeFromIdResult.value.status === 404) { - return left(some(new Error("Bonus Activation not found"))); + return left, BonusActivationWithQrCode>( + some(new Error("Bonus Activation not found")) + ); } // polling should continue - return left(none); + return left, BonusActivationWithQrCode>(none); } else { // we got some error on decoding, stop polling - return left( + return left, BonusActivationWithQrCode>( some( Error(readablePrivacyReport(getLatestBonusVacanzeFromIdResult.value)) ) @@ -78,7 +84,7 @@ function* getBonusActivation( } } catch (e) { // polling should continue - return left(none); + return left, BonusActivationWithQrCode>(none); } } diff --git a/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts b/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts index b7250e0bf1b..0ccfb7fd7fd 100644 --- a/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts +++ b/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts @@ -72,18 +72,18 @@ function* getCheckBonusEligibilitySaga( // 200 -> we got the check result, polling must be stopped if (eligibilityCheckResult.value.status === 200) { const check = eligibilityCheckResult.value.value; - return right(check); + return right, EligibilityCheck>(check); } // polling should continue - return left(none); + return left, EligibilityCheck>(none); } else { // we got some error on decoding, stop polling - return left( + return left, EligibilityCheck>( some(Error(readablePrivacyReport(eligibilityCheckResult.value))) ); } } catch (e) { - return left(none); + return left, EligibilityCheck>(none); } } diff --git a/ts/sagas/contentLoaders.ts b/ts/sagas/contentLoaders.ts index 1854ea69754..8487881d99c 100644 --- a/ts/sagas/contentLoaders.ts +++ b/ts/sagas/contentLoaders.ts @@ -157,9 +157,9 @@ function* fetchMunicipalityMetadata( if (response.value.status !== 200) { throw Error(`response status ${response.value.status}`); } - return right(response.value.value); + return right(response.value.value); } catch (error) { - return left(error); + return left(error); } } diff --git a/ts/sagas/messages/messages.ts b/ts/sagas/messages/messages.ts index 3dd1f2ef35a..4e46e1b1a71 100644 --- a/ts/sagas/messages/messages.ts +++ b/ts/sagas/messages/messages.ts @@ -56,7 +56,7 @@ export function* loadMessage( error }) ); - return left(error); + return left(error); } } @@ -85,12 +85,12 @@ export function* fetchMessage( ? response.value.value.title : `response status ${response.value.status}`; // Return the error - return left(Error(error)); + return left(Error(error)); } return right(response.value.value); } catch (error) { // Return the error - return left(error); + return left(error); } } diff --git a/ts/sagas/user/userMetadata.ts b/ts/sagas/user/userMetadata.ts index 112578aad80..f284656976b 100644 --- a/ts/sagas/user/userMetadata.ts +++ b/ts/sagas/user/userMetadata.ts @@ -49,18 +49,18 @@ export function* fetchUserMetadata( if (response.value.status !== 200) { if (response.value.status === 204) { // Return an empty object cause profile has no metadata yet (204 === No Content) - return right(emptyUserMetadata); + return right(emptyUserMetadata); } const error = response.value.status === 500 ? response.value.value.title : undefined; // Return the error - return left(Error(error)); + return left(Error(error)); } - return right(response.value.value); + return right(response.value.value); } catch (error) { - return left(error); + return left(error); } } @@ -155,12 +155,12 @@ export function* postUserMetadata( const error = response.value.status === 500 ? response.value.value.title : undefined; // Return the error - return left(Error(error)); + return left(Error(error)); } - return right(response.value.value); + return right(response.value.value); } catch (error) { - return left(error); + return left(error); } } From b13cd15d364a11857d31138219f8ee5f1a0bef66 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 11:13:54 +0200 Subject: [PATCH 12/19] fix flagsecure --- ts/components/FlagSecure.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ts/components/FlagSecure.tsx b/ts/components/FlagSecure.tsx index c313398fb86..d000f2035ac 100644 --- a/ts/components/FlagSecure.tsx +++ b/ts/components/FlagSecure.tsx @@ -32,7 +32,4 @@ const mapStateToProps = (state: GlobalState) => ({ isAllowedSnapshotCurrentScreen: isAllowedSnapshotCurrentScreen(state) }); -export default connect( - mapStateToProps, - null -)(FlagSecureComponent); +export default connect(mapStateToProps)(FlagSecureComponent); From 5ea2a248e878d8240aa7ee83dc9b38ef978565ea Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 11:17:57 +0200 Subject: [PATCH 13/19] fix cancel task --- ts/sagas/startup/authenticationSaga.ts | 10 ++++------ .../startup/checkEmailNotificationPreferencesSaga.ts | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ts/sagas/startup/authenticationSaga.ts b/ts/sagas/startup/authenticationSaga.ts index b945653d5d6..e0ebe63ea83 100644 --- a/ts/sagas/startup/authenticationSaga.ts +++ b/ts/sagas/startup/authenticationSaga.ts @@ -14,11 +14,7 @@ import { stopCieManager, watchCieAuthenticationSaga } from "../cie"; * A saga that makes the user go through the authentication process until * a SessionToken gets produced. */ -export function* authenticationSaga(): Generator< - Effect, - SessionToken, - ActionType -> { +export function* authenticationSaga(): Generator { yield put(analyticsAuthenticationStarted()); // Watch for login by CIE @@ -29,7 +25,9 @@ export function* authenticationSaga(): Generator< // Wait until the user has successfully logged in with SPID // FIXME: show an error on LOGIN_FAILED? - const action = yield take(getType(loginSuccess)); + const action: ActionType = yield take( + getType(loginSuccess) + ); yield cancel(watchCieAuthentication); // stop cie manager from listening nfc diff --git a/ts/sagas/startup/checkEmailNotificationPreferencesSaga.ts b/ts/sagas/startup/checkEmailNotificationPreferencesSaga.ts index a81f14a5f07..171c7d71231 100644 --- a/ts/sagas/startup/checkEmailNotificationPreferencesSaga.ts +++ b/ts/sagas/startup/checkEmailNotificationPreferencesSaga.ts @@ -29,11 +29,11 @@ import { profileSelector, ProfileState } from "../../store/reducers/profile"; export function* watchEmailNotificationPreferencesSaga(): Generator< Effect, void, - ReturnType + any > { - const isCustomEmailChannelEnabled = yield select( - isCustomEmailChannelEnabledSelector - ); + const isCustomEmailChannelEnabled: ReturnType< + typeof isCustomEmailChannelEnabledSelector + > = yield select(isCustomEmailChannelEnabledSelector); // if we know about user choice do nothing if (pot.isSome(isCustomEmailChannelEnabled)) { From 24511ea81bf3f8048e599469f9d6e93548c696c2 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 11:30:54 +0200 Subject: [PATCH 14/19] fix right --- ts/sagas/messages/messages.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ts/sagas/messages/messages.ts b/ts/sagas/messages/messages.ts index 4e46e1b1a71..3f6c91090fb 100644 --- a/ts/sagas/messages/messages.ts +++ b/ts/sagas/messages/messages.ts @@ -88,7 +88,9 @@ export function* fetchMessage( return left(Error(error)); } - return right(response.value.value); + return right( + response.value.value + ); } catch (error) { // Return the error return left(error); From 5bb89d0e90a2b460d65d3628ac1ffa41cf5fdcb1 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 12:21:00 +0200 Subject: [PATCH 15/19] fix typescript errors --- ts/sagas/messages/messages.ts | 4 +++- ts/sagas/profile.ts | 4 +--- ts/sagas/wallet.ts | 2 +- ts/types/pagopa.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ts/sagas/messages/messages.ts b/ts/sagas/messages/messages.ts index 3f6c91090fb..895cd914ea8 100644 --- a/ts/sagas/messages/messages.ts +++ b/ts/sagas/messages/messages.ts @@ -33,7 +33,9 @@ export function* loadMessage( // If we already have the message in the store just return it if (cachedMessage !== undefined && pot.isSome(cachedMessage.message)) { - return right(cachedMessage); + return right( + cachedMessage.message.value + ); } try { // Fetch the message from the Backend diff --git a/ts/sagas/profile.ts b/ts/sagas/profile.ts index 49ca1a5a940..977a239487b 100644 --- a/ts/sagas/profile.ts +++ b/ts/sagas/profile.ts @@ -169,7 +169,7 @@ export function* startEmailValidationProcessSaga( >["startEmailValidationProcess"] ): Generator< Effect, - Option, + void, SagaCallReturnType > { try { @@ -180,7 +180,6 @@ export function* startEmailValidationProcessSaga( } if (response.value.status === 202) { yield put(startEmailValidation.success()); - return some(response.value.value); } if (response.value.status === 401) { // in case we got an expired session while loading the profile, we reset @@ -193,7 +192,6 @@ export function* startEmailValidationProcessSaga( } catch (error) { yield put(startEmailValidation.failure(error)); } - return none; } // This function listens for request to send again the email validation to profile email and calls the needed saga. diff --git a/ts/sagas/wallet.ts b/ts/sagas/wallet.ts index 5c34104bb89..16c70580603 100644 --- a/ts/sagas/wallet.ts +++ b/ts/sagas/wallet.ts @@ -146,7 +146,7 @@ function* startOrResumeAddCreditCardSaga( // prepare a new wallet (payment method) that describes the credit card we // want to add const creditCardWallet: NullableWallet = { - idWallet: null, + idWallet: undefined, type: TypeEnum.CREDIT_CARD, favourite: action.payload.setAsFavorite, creditCard: action.payload.creditCard, diff --git a/ts/types/pagopa.ts b/ts/types/pagopa.ts index 6c4a34d905e..37a58f1d919 100644 --- a/ts/types/pagopa.ts +++ b/ts/types/pagopa.ts @@ -108,7 +108,7 @@ export type Wallet = t.TypeOf; /** * A Wallet that has not being saved yet */ -export type NullableWallet = ReplaceProp1; +export type NullableWallet = ReplaceProp1; /** * A refined Transaction From 088e9c37298e5559d120ded300e6f9bf40c4f027 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 12:36:09 +0200 Subject: [PATCH 16/19] fix contentRefreshControl type --- package.json | 2 +- ts/components/screens/DarkLayout.tsx | 9 +++++---- ts/components/screens/ScreenContent.tsx | 6 +++--- ts/components/wallet/WalletLayout.tsx | 12 ++++-------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index cdcac4f764f..998405dbc74 100644 --- a/package.json +++ b/package.json @@ -175,7 +175,7 @@ "ts-jest": "^25.1.0", "ts-node": "^7.0.1", "tslint": "5.20.0", - "typescript": "^3.8.3" + "typescript": "^3.9.7" }, "resolutions": { "@types/react": "16.7.18", diff --git a/ts/components/screens/DarkLayout.tsx b/ts/components/screens/DarkLayout.tsx index 1ae4758d8a3..ba60b33652c 100644 --- a/ts/components/screens/DarkLayout.tsx +++ b/ts/components/screens/DarkLayout.tsx @@ -1,15 +1,15 @@ /** * A component to display a brandDarkGray background color on the screen using it */ -import { View } from "native-base"; +import { Content, View } from "native-base"; import * as React from "react"; import { + Animated, ImageSourcePropType, - RefreshControlProps, StyleProp, + StyleSheet, ViewStyle } from "react-native"; -import { StyleSheet } from "react-native"; import LinearGradient from "react-native-linear-gradient"; import { IconProps } from "react-native-vector-icons/Icon"; import customVariables from "../../theme/variables"; @@ -22,6 +22,7 @@ import { } from "./BaseScreenComponent"; import ScreenContent from "./ScreenContent"; import TopScreenComponent from "./TopScreenComponent"; +import ComponentProps = Animated.ComponentProps; type Props = Readonly<{ accessibilityLabel?: string; @@ -41,7 +42,7 @@ type Props = Readonly<{ footerContent?: React.ReactNode; contextualHelp?: ContextualHelpProps; contextualHelpMarkdown?: ContextualHelpPropsMarkdown; - contentRefreshControl?: React.ReactElement; + contentRefreshControl?: ComponentProps["refreshControl"]; faqCategories?: ReadonlyArray; customGoBack?: React.ReactNode; gradientHeader?: boolean; diff --git a/ts/components/screens/ScreenContent.tsx b/ts/components/screens/ScreenContent.tsx index 01a1cbb2b25..a1d0764dfac 100644 --- a/ts/components/screens/ScreenContent.tsx +++ b/ts/components/screens/ScreenContent.tsx @@ -1,8 +1,8 @@ import { Content } from "native-base"; import * as React from "react"; -import { NavigationEvents } from "react-navigation"; -import { RefreshControlProps, StyleProp, ViewStyle } from "react-native"; +import { StyleProp, ViewStyle } from "react-native"; +import { NavigationEvents } from "react-navigation"; import { ComponentProps } from "../../types/react"; import { ScreenContentHeader } from "./ScreenContentHeader"; @@ -10,7 +10,7 @@ interface OwnProps { hideHeader?: boolean; contentStyle?: StyleProp; bounces?: boolean; - contentRefreshControl?: React.ReactElement; + contentRefreshControl?: ComponentProps["refreshControl"]; } type Props = OwnProps & ComponentProps; diff --git a/ts/components/wallet/WalletLayout.tsx b/ts/components/wallet/WalletLayout.tsx index 124b16036e1..6b833680d3b 100644 --- a/ts/components/wallet/WalletLayout.tsx +++ b/ts/components/wallet/WalletLayout.tsx @@ -8,14 +8,9 @@ * footer with a button for starting a new payment */ -import { Text, View } from "native-base"; +import { Content, Text, View } from "native-base"; import * as React from "react"; -import { - RefreshControlProps, - StyleProp, - StyleSheet, - ViewStyle -} from "react-native"; +import { Animated, StyleProp, StyleSheet, ViewStyle } from "react-native"; import I18n from "../../i18n"; import customVariables from "../../theme/variables"; import { FAQsCategoriesType } from "../../utils/faq"; @@ -25,6 +20,7 @@ import { } from "../screens/BaseScreenComponent"; import DarkLayout from "../screens/DarkLayout"; import H5 from "../ui/H5"; +import ComponentProps = Animated.ComponentProps; type Props = Readonly<{ accessibilityLabel?: string; @@ -36,7 +32,7 @@ type Props = Readonly<{ hideHeader?: boolean; footerContent?: React.ReactNode; contentStyle?: StyleProp; - refreshControl?: React.ReactElement; + refreshControl?: ComponentProps["refreshControl"]; contextualHelp?: ContextualHelpProps; contextualHelpMarkdown?: ContextualHelpPropsMarkdown; faqCategories?: ReadonlyArray; From 709cac449750d226de90f997f57c50692003e79e Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 12:45:09 +0200 Subject: [PATCH 17/19] fix import for babel --- ts/components/screens/DarkLayout.tsx | 3 +-- ts/components/wallet/WalletLayout.tsx | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ts/components/screens/DarkLayout.tsx b/ts/components/screens/DarkLayout.tsx index ba60b33652c..f59036b6d41 100644 --- a/ts/components/screens/DarkLayout.tsx +++ b/ts/components/screens/DarkLayout.tsx @@ -22,7 +22,6 @@ import { } from "./BaseScreenComponent"; import ScreenContent from "./ScreenContent"; import TopScreenComponent from "./TopScreenComponent"; -import ComponentProps = Animated.ComponentProps; type Props = Readonly<{ accessibilityLabel?: string; @@ -42,7 +41,7 @@ type Props = Readonly<{ footerContent?: React.ReactNode; contextualHelp?: ContextualHelpProps; contextualHelpMarkdown?: ContextualHelpPropsMarkdown; - contentRefreshControl?: ComponentProps["refreshControl"]; + contentRefreshControl?: Animated.ComponentProps["refreshControl"]; faqCategories?: ReadonlyArray; customGoBack?: React.ReactNode; gradientHeader?: boolean; diff --git a/ts/components/wallet/WalletLayout.tsx b/ts/components/wallet/WalletLayout.tsx index 6b833680d3b..345388a858c 100644 --- a/ts/components/wallet/WalletLayout.tsx +++ b/ts/components/wallet/WalletLayout.tsx @@ -20,7 +20,6 @@ import { } from "../screens/BaseScreenComponent"; import DarkLayout from "../screens/DarkLayout"; import H5 from "../ui/H5"; -import ComponentProps = Animated.ComponentProps; type Props = Readonly<{ accessibilityLabel?: string; @@ -32,7 +31,7 @@ type Props = Readonly<{ hideHeader?: boolean; footerContent?: React.ReactNode; contentStyle?: StyleProp; - refreshControl?: ComponentProps["refreshControl"]; + refreshControl?: Animated.ComponentProps["refreshControl"]; contextualHelp?: ContextualHelpProps; contextualHelpMarkdown?: ContextualHelpPropsMarkdown; faqCategories?: ReadonlyArray; From ebb0b117f724afeaa94a74a6b76d22a09b88f098 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 12:50:26 +0200 Subject: [PATCH 18/19] fix yarn lock --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 3be2035b28d..4865ab87152 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11371,7 +11371,7 @@ typescript-tuple@^2.2.1: dependencies: typescript-compare "^0.0.2" -typescript@^3.8.3: +typescript@^3.9.7: version "3.9.7" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== From e8b76429c37183c20c67c701ef30211c18335be5 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 14 Aug 2020 15:31:31 +0200 Subject: [PATCH 19/19] remove test on message cache --- ts/sagas/messages/__tests__/messages.test.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/ts/sagas/messages/__tests__/messages.test.ts b/ts/sagas/messages/__tests__/messages.test.ts index 0dbc535d8a0..e36f4d4cf4b 100644 --- a/ts/sagas/messages/__tests__/messages.test.ts +++ b/ts/sagas/messages/__tests__/messages.test.ts @@ -1,7 +1,6 @@ import { left, right } from "fp-ts/lib/Either"; import * as t from "io-ts"; -import * as pot from "italia-ts-commons/lib/pot"; import { testSaga } from "redux-saga-test-plan"; import { CreatedMessageWithContentAndAttachments } from "../../../../definitions/backend/CreatedMessageWithContentAndAttachments"; @@ -65,20 +64,6 @@ describe("messages", () => { }); describe("loadMessage test plan", () => { - it("should return the cached message if the message is in the cache", () => { - const getMessage = jest.fn(); - testSaga(loadMessage, getMessage, testMessageWithContent1) - .next() - .next({ - message: pot.some(testMessageWithContent1) - }) - .returns( - right({ - message: pot.some(testMessageWithContent1) - }) - ); - }); - it("should call fetchMessage with the right parameters", () => { const getMessage = jest.fn(); testSaga(loadMessage, getMessage, testMessageWithContent1)