Skip to content

Commit

Permalink
Merge branch 'master' into IOBP-885-add-last-payment-used
Browse files Browse the repository at this point in the history
  • Loading branch information
hevelius authored Oct 14, 2024
2 parents ca5f33e + a125904 commit 8f638bb
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 107 deletions.
12 changes: 0 additions & 12 deletions ts/api/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import {
getServicePreferencesDefaultDecoder,
GetServicePreferencesT,
GetServiceT,
getSupportTokenDefaultDecoder,
GetSupportTokenT,
getUserDataProcessingDefaultDecoder,
GetUserDataProcessingT,
getUserMessageDefaultDecoder,
Expand Down Expand Up @@ -340,13 +338,6 @@ export function BackendClient(
response_decoder: getActivationStatusDefaultDecoder()
};

const getSupportToken: GetSupportTokenT = {
method: "get",
url: () => `/api/v1/token/support`,
headers: tokenHeaderProducer,
query: () => ({}),
response_decoder: getSupportTokenDefaultDecoder()
};
const withBearerToken = withToken(token);
return {
getSession: withBearerToken(createFetchRequestForApi(getSessionT, options)),
Expand Down Expand Up @@ -418,9 +409,6 @@ export function BackendClient(
postUserDataProcessingRequest: withBearerToken(
createFetchRequestForApi(postUserDataProcessingT, options)
),
getSupportToken: withBearerToken(
createFetchRequestForApi(getSupportToken, options)
),
deleteUserDataProcessingRequest: withBearerToken(
createFetchRequestForApi(deleteUserDataProcessingT, options)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Platform } from "react-native";
import {
ListItemHeader,
VSpacer,
Expand All @@ -19,6 +20,13 @@ export type WalletCardsCategoryContainerProps = WithTestID<{
topElement?: JSX.Element;
}>;

// The item layout animation has a bug on Android for a FlatList that doesn't have a fixed height [https://github.com/software-mansion/react-native-reanimated/issues/5728]
// * The animations work perfectly when an item enters, but when removing an item, there is always a UI bug where the last item becomes invisible during rendering.
// * Even with an hardcoded height with the onLayout event, the bug is still present
// * The workaround is to disable the layout animation on Android
const itemLayoutAnimation =
Platform.OS !== "android" ? LinearTransition.duration(200) : undefined;

/**
* This component handles the rendering of cards of a specific category.
* The component also handles logic behind card stacking and animations
Expand All @@ -40,7 +48,7 @@ export const WalletCardsCategoryContainer = ({
renderItem={({ index, item }) =>
renderWalletCardFn(item, isStacked && index < cards.length - 1)
}
itemLayoutAnimation={LinearTransition.duration(200)}
itemLayoutAnimation={itemLayoutAnimation}
entering={FadeInDown.duration(150)}
exiting={FadeOutDown.duration(150)}
/>
Expand Down
6 changes: 1 addition & 5 deletions ts/features/zendesk/saga/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import {
zendeskStartPolling,
zendeskSupportCompleted,
zendeskSupportStart,
getZendeskToken,
zendeskSupportCancel
getZendeskToken
} from "../store/actions";
import { ContentClient } from "../../../api/content";
import { dismissSupport } from "../../../utils/supportAssistance";
Expand Down Expand Up @@ -137,9 +136,6 @@ function* getZendeskTokenSaga(
);
return;
}
if (response.right.status === 401) {
yield* put(zendeskSupportCancel());
}
if (!isFastLogin || response.right.status !== 401) {
yield* put(getZendeskToken.failure());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useCallback } from "react";
import { OperationResultScreenContent } from "../../../components/screens/OperationResultScreenContent";
import { useIONavigation } from "../../../navigation/params/AppParamsList";
import I18n from "../../../i18n";
import { useIODispatch } from "../../../store/hooks";
import { zendeskSupportCancel } from "../store/actions";

const RequestZandeskTokenErrorScreen = () => {
const navigation = useIONavigation();
const dispatch = useIODispatch();

const handleOnClose = useCallback(() => {
navigation.goBack();
}, [navigation]);
dispatch(zendeskSupportCancel());
}, [dispatch]);

return (
<OperationResultScreenContent
Expand Down
1 change: 0 additions & 1 deletion ts/sagas/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ export function* initializeApplicationSaga(
yield* fork(
watchCheckSessionSaga,
backendClient.getSession,
backendClient.getSupportToken,
formatRequestedTokenString()
);
// Start watching for requests of abort the onboarding
Expand Down
29 changes: 0 additions & 29 deletions ts/sagas/startup/watchCheckSessionSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,13 @@ import { GetSessionStateT } from "../../../definitions/session_manager/requestTy
import { BackendClient } from "../../api/backend";
import {
checkCurrentSession,
loadSupportToken,
sessionInformationLoadSuccess
} from "../../store/actions/authentication";
import { ReduxSagaEffect, SagaCallReturnType } from "../../types/utils";
import { isTestEnv } from "../../utils/environment";
import { convertUnknownToError } from "../../utils/errors";
import { handleSessionExpiredSaga } from "../../features/fastLogin/saga/utils";

// load the support token useful for user assistance
function* handleLoadSupportToken(
getSupportToken: ReturnType<typeof BackendClient>["getSupportToken"]
): SagaIterator {
try {
const response: SagaCallReturnType<typeof getSupportToken> = yield* call(
getSupportToken,
{}
);
if (E.isLeft(response)) {
throw Error(readableReport(response.left));
} else {
if (response.right.status === 200) {
yield* put(loadSupportToken.success(response.right.value));
} else {
throw Error(`response status code ${response.right.status}`);
}
}
} catch (e) {
yield* put(loadSupportToken.failure(convertUnknownToError(e)));
}
}

export function* checkSession(
getSessionValidity: ReturnType<typeof BackendClient>["getSession"],
fields?: string // the `fields` parameter is optional and it defaults to an empty object
Expand Down Expand Up @@ -85,17 +61,12 @@ export function* checkSessionResult(
// Saga that listen to check session dispatch and returns it's validity
export function* watchCheckSessionSaga(
getSessionValidity: ReturnType<typeof BackendClient>["getSession"],
getSupportToken: ReturnType<typeof BackendClient>["getSupportToken"],
fields?: string
): SagaIterator {
yield* takeLatest(getType(checkCurrentSession.request), function* () {
yield* call(checkSession, getSessionValidity, fields);
});
yield* takeLatest(getType(checkCurrentSession.success), checkSessionResult);

yield* takeLatest(getType(loadSupportToken.request), function* () {
yield* call(handleLoadSupportToken, getSupportToken);
});
}

export const testableCheckSession = isTestEnv ? checkSession : undefined;
8 changes: 0 additions & 8 deletions ts/store/actions/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { PublicSession } from "../../../definitions/session_manager/PublicSession";
import { PasswordLogin } from "../../../definitions/session_manager/PasswordLogin";
import { SessionToken } from "../../types/SessionToken";
import { SupportToken } from "../../../definitions/backend/SupportToken";
import { SpidIdp } from "../../../definitions/content/SpidIdp";
import { IdpData } from "../../../definitions/content/IdpData";

Expand Down Expand Up @@ -83,12 +82,6 @@ export const checkCurrentSession = createAsyncAction(
"CHECK_CURRENT_SESSION_FAILURE"
)<void, CheckSessionResult, Error>();

export const loadSupportToken = createAsyncAction(
"LOAD_TOKEN_SUPPORT_REQUEST",
"LOAD_TOKEN_SUPPORT_SUCCESS",
"LOAD_TOKEN_SUPPORT_FAILURE"
)<void, SupportToken, Error>();

export const sessionExpired = createStandardAction("SESSION_EXPIRED")();

export const sessionInvalid = createStandardAction("SESSION_INVALID")();
Expand All @@ -109,5 +102,4 @@ export type AuthenticationActions =
| ActionType<typeof sessionExpired>
| ActionType<typeof sessionInvalid>
| ActionType<typeof resetAuthenticationState>
| ActionType<typeof loadSupportToken>
| ActionType<typeof disableNativeAuthentication>;
47 changes: 0 additions & 47 deletions ts/store/reducers/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { PublicSession } from "../../../definitions/session_manager/PublicSessio
import { SessionToken } from "../../types/SessionToken";
import {
idpSelected,
loadSupportToken,
loginSuccess,
logoutFailure,
logoutSuccess,
Expand All @@ -16,14 +15,6 @@ import {
sessionInvalid
} from "../actions/authentication";
import { Action } from "../actions/types";
import {
remoteError,
remoteLoading,
remoteReady,
remoteUndefined,
RemoteValue
} from "../../common/model/RemoteValue";
import { SupportToken } from "../../../definitions/backend/SupportToken";
import { SpidIdp } from "../../../definitions/content/SpidIdp";
import { refreshSessionToken } from "../../features/fastLogin/store/actions/tokenRefreshActions";
import { logoutRequest } from "./../actions/authentication";
Expand Down Expand Up @@ -60,14 +51,12 @@ export type LoggedInWithoutSessionInfo = Readonly<{
sessionToken: SessionToken;
}>;

export type SupportTokenState = RemoteValue<SupportToken, Error>;
// The user is logged in and we also have all session info
export type LoggedInWithSessionInfo = Readonly<{
kind: "LoggedInWithSessionInfo";
idp: SpidIdp;
sessionToken: SessionToken;
sessionInfo: PublicSession;
supportToken?: SupportTokenState;
}>;

export type LogoutRequested = Readonly<{
Expand Down Expand Up @@ -176,11 +165,6 @@ export const sessionInfoSelector = createSelector(
: O.none
);

export const supportTokenSelector = (state: GlobalState): SupportTokenState =>
isLoggedInWithSessionInfo(state.authentication)
? state.authentication.supportToken ?? remoteUndefined
: remoteUndefined;

export const zendeskTokenSelector = (state: GlobalState): string | undefined =>
isLoggedInWithSessionInfo(state.authentication)
? state.authentication.sessionInfo.zendeskToken
Expand Down Expand Up @@ -227,7 +211,6 @@ export const idpSelector = ({
export const loggedInAuthSelector = ({ authentication }: GlobalState) =>
isLoggedIn(authentication) ? authentication : undefined;

// eslint-disable-next-line complexity
const reducer = (
state: AuthenticationState = INITIAL_STATE,
action: Action
Expand All @@ -244,36 +227,6 @@ const reducer = (
};
}

if (
isActionOf(loadSupportToken.request, action) &&
isLoggedInWithSessionInfo(state)
) {
return {
...state,
supportToken: remoteLoading
};
}

if (
isActionOf(loadSupportToken.success, action) &&
isLoggedInWithSessionInfo(state)
) {
return {
...state,
supportToken: remoteReady(action.payload)
};
}

if (
isActionOf(loadSupportToken.failure, action) &&
isLoggedInWithSessionInfo(state)
) {
return {
...state,
supportToken: remoteError(action.payload)
};
}

if (isActionOf(loginSuccess, action) && isLoggedOutWithIdp(state)) {
// Save the SessionToken (got from the WebView redirect url) in the state
return {
Expand Down

0 comments on commit 8f638bb

Please sign in to comment.