TP-73673 | TP-74249 | Remove Shimmer & QuoteID Caching (#11822)

This commit is contained in:
Prajjaval Verma
2024-07-19 01:01:24 +05:30
committed by GitHub
parent 05768ca90a
commit 1cc756b63b
10 changed files with 68 additions and 282 deletions

35
App.tsx
View File

@@ -1,11 +1,18 @@
import { init } from "@sentry/react-native"; import { init } from "@sentry/react-native";
import { Component } from "react"; import { Component } from "react";
import codePush from "react-native-code-push"; import codePush from "react-native-code-push";
import {
GenericErrorScreen
} from "./App/Container/Navi-Insurance";
import { import {
BundleState, BundleState,
CODEPUSH_METHOD, CODEPUSH_METHOD,
EVENT_NAMES,
EVENT_PROPERTY_KEYS,
EVENT_PROPERTY_VALUES,
SentryConstants, SentryConstants,
} from "./App/common/constants"; } from "./App/common/constants";
import { sendAsAnalyticsEvent } from "./App/common/hooks/useAnalyticsEvent";
import { logToSentry } from "./App/common/hooks/useSentryLogging"; import { logToSentry } from "./App/common/hooks/useSentryLogging";
import { CtaData } from "./App/common/interface"; import { CtaData } from "./App/common/interface";
import RnApp from "./App/common/navigator/RnAppCreator"; import RnApp from "./App/common/navigator/RnAppCreator";
@@ -13,20 +20,10 @@ import {
getBuildConfigDetails, getBuildConfigDetails,
setBuildConfigDetails, setBuildConfigDetails,
} from "./App/common/utilities/CacheUtils"; } from "./App/common/utilities/CacheUtils";
import {
GenericErrorScreen,
GenericShimmerScreen,
} from "./App/Container/Navi-Insurance";
import { import {
getStringPreference, getStringPreference,
setStringPreference, setStringPreference,
} from "./App/common/utilities/SharedPreferenceUtils"; } from "./App/common/utilities/SharedPreferenceUtils";
import { sendAsAnalyticsEvent } from "./App/common/hooks/useAnalyticsEvent";
import {
EVENT_NAMES,
EVENT_PROPERTY_KEYS,
EVENT_PROPERTY_VALUES,
} from "./App/common/constants";
init({ init({
dsn: SentryConstants.SENTRY_DSN, dsn: SentryConstants.SENTRY_DSN,
@@ -53,9 +50,10 @@ export default class App extends Component<{}, AppState> {
getBuildConfigDetails().then(res => { getBuildConfigDetails().then(res => {
flavor = res?.baseUrl; flavor = res?.baseUrl;
}); });
const cta = this.getInitialCta();
await codePush.sync( await codePush.sync(
{ {
installMode: codePush.InstallMode.IMMEDIATE, installMode: (cta?.title === preloadBundle) ? codePush.InstallMode.IMMEDIATE : codePush.InstallMode.ON_NEXT_RESTART,
mandatoryInstallMode: codePush.InstallMode.IMMEDIATE, mandatoryInstallMode: codePush.InstallMode.IMMEDIATE,
}, },
status => { status => {
@@ -145,12 +143,15 @@ export default class App extends Component<{}, AppState> {
if (cta?.title === preloadBundle) { if (cta?.title === preloadBundle) {
return <></>; return <></>;
} }
else if (!!cta){
return !!cta && this.state.bundleState !== BundleState.LOADING ? ( return RnApp.create(cta)
RnApp.create(cta) }
) : ( else {
<GenericShimmerScreen /> sendAsAnalyticsEvent({
); name: EVENT_NAMES.INVALID_SCREEN_CTA
});
return <GenericErrorScreen />;
}
} }
} }

View File

@@ -1,16 +1,12 @@
import { View } from "react-native"; import { View } from "react-native";
import SkeletonPlaceholder from "react-native-skeleton-placeholder"; import SkeletonPlaceholder from "react-native-skeleton-placeholder";
import Colors from "../../../../../assets/colors/colors"; import Colors from "../../../../../assets/colors/colors";
import styles from "./GenericShimmerScreenStyle";
import { StaticHeader } from "../../../../../components/reusable/static-header/StaticHeader"; import { StaticHeader } from "../../../../../components/reusable/static-header/StaticHeader";
import { CtaData, CtaType } from "../../../../common/interface";
import { ConstantCta } from "../../../../common/constants/CtaConstants"; import { ConstantCta } from "../../../../common/constants/CtaConstants";
import { logToSentry } from "../../../../common/hooks/useSentryLogging"; import { logToSentry } from "../../../../common/hooks/useSentryLogging";
import { import { CtaData, CtaType } from "../../../../common/interface";
invalidateCacheWithUrl,
shouldInvalidateSavedData,
} from "../../../../common/utilities/CacheUtils";
import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules"; import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules";
import styles from "./GenericShimmerScreenStyle";
const GenericShimmerScreen = () => { const GenericShimmerScreen = () => {
const handleClick = (cta?: CtaData) => { const handleClick = (cta?: CtaData) => {
@@ -21,10 +17,6 @@ const GenericShimmerScreen = () => {
return; return;
} }
if (invalidateCacheWithUrl(cta.url) || shouldInvalidateSavedData(cta)) {
invalidatePostApiData();
}
try { try {
switch (cta.type) { switch (cta.type) {
case CtaType.DEEP_LINK: case CtaType.DEEP_LINK:
@@ -99,6 +91,3 @@ const FooterShimmer = () => {
</View> </View>
); );
}; };
function invalidatePostApiData() {
throw new Error("Function not implemented.");
}

View File

@@ -1,23 +1,19 @@
import { TouchableOpacity, View, Text } from "react-native"; import { Text, TouchableOpacity, View } from "react-native";
import { GenericActionPayload } from "../../../../common/actions/GenericAction";
import { CtaData, CtaType } from "../../../../common/interface";
import { ScreenData } from "../../../../common/interface/widgets/screenData/ScreenData";
import { AppImage } from "../../../../../components/AppImage"; import { AppImage } from "../../../../../components/AppImage";
import { StaticHeader } from "../../../../../components/reusable/static-header/StaticHeader";
import { GenericActionPayload } from "../../../../common/actions/GenericAction";
import { ConstantCta } from "../../../../common/constants/CtaConstants";
import { import {
ImageName, ImageName,
QUOTE_APOLOGY_BUTTON, QUOTE_APOLOGY_BUTTON,
QUOTE_APOLOGY_SUBTITLE, QUOTE_APOLOGY_SUBTITLE,
QUOTE_APOLOGY_TITLE, QUOTE_APOLOGY_TITLE,
} from "../../../../common/constants/StringConstant"; } from "../../../../common/constants/StringConstant";
import { CtaData, CtaType } from "../../../../common/interface";
import { ScreenData } from "../../../../common/interface/widgets/screenData/ScreenData";
import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules"; import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules";
import { styles } from "./QuoteApologyScreenStyle";
import { StaticHeader } from "../../../../../components/reusable/static-header/StaticHeader";
import { ConstantCta } from "../../../../common/constants/CtaConstants";
import {
invalidateCacheWithUrl,
shouldInvalidateSavedData,
} from "../../../../common/utilities/CacheUtils";
import { setStringPreference } from "../../../../common/utilities/SharedPreferenceUtils"; import { setStringPreference } from "../../../../common/utilities/SharedPreferenceUtils";
import { styles } from "./QuoteApologyScreenStyle";
const QuoteApologyScreen = ({ const QuoteApologyScreen = ({
ctaData, ctaData,
@@ -28,17 +24,8 @@ const QuoteApologyScreen = ({
screenData: ScreenData | null; screenData: ScreenData | null;
handleActions: (screenPayload?: GenericActionPayload) => void; handleActions: (screenPayload?: GenericActionPayload) => void;
}) => { }) => {
const invalidatePostApiData = () => {
return setStringPreference("POST_API_CALLED", "false");
};
const handleClick = (cta?: CtaData) => { const handleClick = (cta?: CtaData) => {
if (!cta) return; // Handle case when cta is undefined or null if (!cta) return; // Handle case when cta is undefined or null
if (invalidateCacheWithUrl(cta.url) || shouldInvalidateSavedData(cta)) {
invalidatePostApiData();
}
try { try {
switch (cta.type) { switch (cta.type) {
case CtaType.DEEP_LINK: case CtaType.DEEP_LINK:

View File

@@ -1,10 +1,12 @@
import { useNavigation } from "@react-navigation/native";
import throttle from "lodash/throttle";
import React, { useCallback, useEffect } from "react"; import React, { useCallback, useEffect } from "react";
import { import {
EmitterSubscription, EmitterSubscription,
NativeEventEmitter, NativeEventEmitter,
NativeScrollEvent, NativeScrollEvent,
NativeSyntheticEvent, NativeSyntheticEvent,
View, View
} from "react-native"; } from "react-native";
import Animated, { import Animated, {
useAnimatedStyle, useAnimatedStyle,
@@ -13,10 +15,12 @@ import Animated, {
} from "react-native-reanimated"; } from "react-native-reanimated";
import Colors from "../../../../../assets/colors/colors"; import Colors from "../../../../../assets/colors/colors";
import BaseWidget from "../../../../../components/widgets/BaseWidget"; import BaseWidget from "../../../../../components/widgets/BaseWidget";
import FAB from "../../../../../components/widgets/fab/FAB";
import { import {
BaseActionTypes, BaseActionTypes,
GenericActionPayload, GenericActionPayload,
} from "../../../../common/actions/GenericAction"; } from "../../../../common/actions/GenericAction";
import { ConstantCta, ScreenProperties } from "../../../../common/constants";
import { AnalyticsEventNameConstants } from "../../../../common/constants/AnalyticsEventsConstant"; import { AnalyticsEventNameConstants } from "../../../../common/constants/AnalyticsEventsConstant";
import { NativeEventNameConstants } from "../../../../common/constants/EventNameConstants"; import { NativeEventNameConstants } from "../../../../common/constants/EventNameConstants";
import { import {
@@ -30,27 +34,15 @@ import { Widget } from "../../../../common/interface/widgets/Widget";
import { ScreenData } from "../../../../common/interface/widgets/screenData/ScreenData"; import { ScreenData } from "../../../../common/interface/widgets/screenData/ScreenData";
import { FabWidgetData } from "../../../../common/interface/widgets/widgetData/FabWidgetData"; import { FabWidgetData } from "../../../../common/interface/widgets/widgetData/FabWidgetData";
import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules"; import { NativeDeeplinkNavigatorModule } from "../../../../common/native-module/NativeModules";
import {
CtaNavigator,
extractCtaParameters,
} from "../../../../common/navigator/NavigationRouter";
import { ScreenState } from "../../../../common/screen/BaseScreen"; import { ScreenState } from "../../../../common/screen/BaseScreen";
import { ScreenActionTypes } from "../../../../common/screen/ScreenActionTypes"; import { ScreenActionTypes } from "../../../../common/screen/ScreenActionTypes";
import styles from "./QuoteOfferScreenStyle"; import styles from "./QuoteOfferScreenStyle";
import QuoteOfferErrorScreen from "./error-screen/QuoteOfferErrorScreen"; import QuoteOfferErrorScreen from "./error-screen/QuoteOfferErrorScreen";
import QuoteOfferShimmerScreen from "./shimmer-screen/QuoteOfferShimmerScreen"; import QuoteOfferShimmerScreen from "./shimmer-screen/QuoteOfferShimmerScreen";
import FAB from "../../../../../components/widgets/fab/FAB";
import { useNavigation } from "@react-navigation/native";
import {
CtaNavigator,
extractCtaParameters,
} from "../../../../common/navigator/NavigationRouter";
import {
getStringPreference,
setStringPreference,
} from "../../../../common/utilities/SharedPreferenceUtils";
import {
invalidateCacheWithUrl,
shouldInvalidateSavedData,
} from "../../../../common/utilities/CacheUtils";
import throttle from "lodash/throttle";
import { ConstantCta, ScreenProperties } from "../../../../common/constants";
const QuoteOfferScreen = ({ const QuoteOfferScreen = ({
ctaData, ctaData,
screenData, screenData,
@@ -107,14 +99,6 @@ const QuoteOfferScreen = ({
const { preQuoteId, quoteId, navigatorType } = extractCtaParameters(ctaData); const { preQuoteId, quoteId, navigatorType } = extractCtaParameters(ctaData);
const validatePostApiData = async () => {
return await getStringPreference("POST_API_CALLED", "string");
};
const invalidatePostApiData = () => {
return setStringPreference("POST_API_CALLED", "false");
};
const nativeEventListener = new NativeEventEmitter(); const nativeEventListener = new NativeEventEmitter();
let reloadPageEventListener = {} as EmitterSubscription; let reloadPageEventListener = {} as EmitterSubscription;
@@ -126,10 +110,6 @@ const QuoteOfferScreen = ({
return; return;
} }
if (invalidateCacheWithUrl(cta.url) || shouldInvalidateSavedData(cta)) {
invalidatePostApiData();
}
try { try {
switch (cta.type) { switch (cta.type) {
case CtaType.DEEP_LINK: case CtaType.DEEP_LINK:
@@ -163,19 +143,10 @@ const QuoteOfferScreen = ({
); );
useEffect(() => { useEffect(() => {
let postApiCalled = "false"; const screenActionType = preQuoteId
validatePostApiData() ? ScreenActionTypes.FETCH_QUOTE_V4
.then(value => { : ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
postApiCalled = value; const data: QuoteOfferRequest = {
})
.then(() => {
const screenActionType =
postApiCalled === "true"
? ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND
: preQuoteId
? ScreenActionTypes.FETCH_QUOTE_V4
: ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
const data: QuoteOfferRequest = {
preQuoteId: preQuoteId ? preQuoteId : undefined, preQuoteId: preQuoteId ? preQuoteId : undefined,
quoteId: quoteId ? quoteId : undefined, quoteId: quoteId ? quoteId : undefined,
}; };
@@ -188,7 +159,6 @@ const QuoteOfferScreen = ({
}, },
], ],
}); });
});
return () => {}; return () => {};
}, [ctaData, preQuoteId, quoteId]); }, [ctaData, preQuoteId, quoteId]);
@@ -197,18 +167,9 @@ const QuoteOfferScreen = ({
NativeEventNameConstants.reloadPage, NativeEventNameConstants.reloadPage,
event => { event => {
if (event === true) { if (event === true) {
let postApiCalled = "false"; const screenActionType = preQuoteId
validatePostApiData() ? ScreenActionTypes.FETCH_QUOTE_V4
.then(value => { : ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
postApiCalled = value;
})
.then(() => {
const screenActionType =
postApiCalled === "true"
? ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND
: preQuoteId
? ScreenActionTypes.FETCH_QUOTE_V4
: ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND;
const data: QuoteOfferRequest = { const data: QuoteOfferRequest = {
preQuoteId: preQuoteId ? preQuoteId : undefined, preQuoteId: preQuoteId ? preQuoteId : undefined,
quoteId: quoteId ? quoteId : undefined, quoteId: quoteId ? quoteId : undefined,
@@ -222,7 +183,6 @@ const QuoteOfferScreen = ({
}, },
], ],
}); });
});
} }
}, },
); );

View File

@@ -42,6 +42,7 @@ export const AnalyticsGlobalErrorTypeConstant = {
export const EVENT_NAMES = { export const EVENT_NAMES = {
CODEPUSH_FETCH_ERROR: "codepush_fetch_error", CODEPUSH_FETCH_ERROR: "codepush_fetch_error",
SCREEN_LOAD_TIME: "react_screen_load_time", SCREEN_LOAD_TIME: "react_screen_load_time",
INVALID_SCREEN_CTA: "invalid_screen_cta",
}; };
export const EVENT_PROPERTY_KEYS = { export const EVENT_PROPERTY_KEYS = {

View File

@@ -7,7 +7,7 @@ import { GZIP } from "../../../network/NetworkConstant";
import { get, post } from "../../../network/NetworkService"; import { get, post } from "../../../network/NetworkService";
import { mergeHeaders } from "../../../network/NetworkUtils"; import { mergeHeaders } from "../../../network/NetworkUtils";
import { ActionMetaData, BaseActionTypes } from "../actions/GenericAction"; import { ActionMetaData, BaseActionTypes } from "../actions/GenericAction";
import { BASE_SCREEN, GI, QUOTE_ID } from "../constants"; import { BASE_SCREEN, GI } from "../constants";
import { import {
AnalyticsFlowNameConstant, AnalyticsFlowNameConstant,
AnalyticsGlobalErrorTypeConstant, AnalyticsGlobalErrorTypeConstant,
@@ -21,10 +21,6 @@ import {
import { logToSentry } from "../hooks/useSentryLogging"; import { logToSentry } from "../hooks/useSentryLogging";
import { CtaData } from "../interface"; import { CtaData } from "../interface";
import { ScreenData } from "../interface/widgets/screenData/ScreenData"; import { ScreenData } from "../interface/widgets/screenData/ScreenData";
import {
getStringPreference,
setStringPreference,
} from "../utilities/SharedPreferenceUtils";
import { ScreenState } from "./BaseScreen"; import { ScreenState } from "./BaseScreen";
import { ScreenActionTypes } from "./ScreenActionTypes"; import { ScreenActionTypes } from "./ScreenActionTypes";
@@ -38,48 +34,22 @@ export const ScreenActionHandler = {
switch (screenMetaData.actionType) { switch (screenMetaData.actionType) {
case ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND: { case ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND: {
let quoteId = screenMetaData.data.quoteId; let quoteId = screenMetaData.data.quoteId;
if (!quoteId) { return get<ApiResponse<CtaData>>(
getQuoteIdFromCache().then(value => {
if (!!value) {
quoteId = value;
return get<ApiResponse<CtaData>>(
`v3/quotes/${quoteId}`,
getXTargetHeaderInfo(GI.toLocaleUpperCase()),
)
.then(response => {
handleResponseData(setScreenData, response);
})
.catch(error => {
handleErrorData(
error,
setScreenData,
screenMetaData,
AnalyticsMethodNameConstant.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
);
});
}
return;
});
} else {
return get<ApiResponse<CtaData>>(
`v3/quotes/${quoteId}`, `v3/quotes/${quoteId}`,
getXTargetHeaderInfo(GI.toLocaleUpperCase()), getXTargetHeaderInfo(GI.toLocaleUpperCase()),
) )
.then(response => { .then(response => {
handleResponseData(setScreenData, response); handleResponseData(setScreenData, response);
}) })
.catch(error => { .catch(error => {
handleErrorData( handleErrorData(
error, error,
setScreenData, setScreenData,
screenMetaData, screenMetaData,
AnalyticsMethodNameConstant.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND, AnalyticsMethodNameConstant.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND, ScreenActionTypes.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
); );
}); });
}
return;
} }
case ScreenActionTypes.FETCH_QUOTE_V3: { case ScreenActionTypes.FETCH_QUOTE_V3: {
return post<ApiResponse<CtaData>>( return post<ApiResponse<CtaData>>(
@@ -91,18 +61,8 @@ export const ScreenActionHandler = {
if (screenData?.screenState) { if (screenData?.screenState) {
screenData.screenState = ScreenState.LOADING; screenData.screenState = ScreenState.LOADING;
} }
setPostApiData();
if (response.data) { if (response.data) {
const cta = response.data as CtaData; const cta = response.data as CtaData;
let quoteId;
cta?.parameters?.forEach(item => {
if (item.key === "quoteId") {
quoteId = item.value;
}
});
if (!!quoteId) {
storeQuoteId(quoteId);
}
// By default routing is happening via Base screen hence below navigate sends the cta there to get routed to specific screenName based on Cta // By default routing is happening via Base screen hence below navigate sends the cta there to get routed to specific screenName based on Cta
if (!!cta.analyticsEventProperties) { if (!!cta.analyticsEventProperties) {
sendAsAnalyticsEvent(cta.analyticsEventProperties); sendAsAnalyticsEvent(cta.analyticsEventProperties);
@@ -159,23 +119,11 @@ export const ScreenActionHandler = {
screenState: ScreenState.LOADING, screenState: ScreenState.LOADING,
}); });
} }
setPostApiData();
if (response) { if (response) {
const updatedScreenData: ScreenData = { const updatedScreenData: ScreenData = {
...(response.data as ScreenData), ...(response.data as ScreenData),
screenState: ScreenState.LOADED, screenState: ScreenState.LOADED,
}; };
let quoteId;
updatedScreenData?.screenMetaData?.screenProperties?.forEach(
item => {
if (item.key === QUOTE_ID) {
quoteId = item.value;
}
},
);
if (!!quoteId) {
storeQuoteId(quoteId);
}
// If redirectionCta is present and screenWidgets is not present then navigate to Base screen to get routed to specific screenName based on Cta // If redirectionCta is present and screenWidgets is not present then navigate to Base screen to get routed to specific screenName based on Cta
if ( if (
!!updatedScreenData.screenMetaData?.redirectionCta && !!updatedScreenData.screenMetaData?.redirectionCta &&
@@ -240,18 +188,6 @@ export const ScreenActionHandler = {
}, },
}; };
const setPostApiData = () => {
return setStringPreference("POST_API_CALLED", "true");
};
const storeQuoteId = (quoteId: string) => {
return setStringPreference("QUOTE_ID", quoteId);
};
const getQuoteIdFromCache = async () => {
return await getStringPreference("QUOTE_ID", "string");
};
const handleResponseData = ( const handleResponseData = (
setScreenData: Dispatch<SetStateAction<ScreenData | null>>, setScreenData: Dispatch<SetStateAction<ScreenData | null>>,
response: any, response: any,

View File

@@ -1,9 +1,8 @@
import AsyncStorage from "@react-native-async-storage/async-storage"; import AsyncStorage from "@react-native-async-storage/async-storage";
import { BUY_INSURANCE_SCREEN, COMPARE_PLAN_SCREEN, QUOTE_OFFER_SCREEN } from "../constants/ScreenNameConstants";
import { ScreenData } from "../interface/widgets/screenData/ScreenData";
import { NetworkConnectorModule } from "../../common/native-module/NativeModules"; import { NetworkConnectorModule } from "../../common/native-module/NativeModules";
import { BUY_INSURANCE_SCREEN, COMPARE_PLAN_SCREEN, QUOTE_OFFER_SCREEN } from "../constants/ScreenNameConstants";
import { BUILD_CONFIG_DETAILS } from "../constants/StringConstant"; import { BUILD_CONFIG_DETAILS } from "../constants/StringConstant";
import { CtaData } from "../interface"; import { ScreenData } from "../interface/widgets/screenData/ScreenData";
export const getScreenDataFromCache = async ( export const getScreenDataFromCache = async (
key: string key: string
@@ -88,24 +87,3 @@ export const isScreenWhiteListedForCaching = (
}; };
export const screensWithCachingDisabled = [BUY_INSURANCE_SCREEN, QUOTE_OFFER_SCREEN, COMPARE_PLAN_SCREEN]; export const screensWithCachingDisabled = [BUY_INSURANCE_SCREEN, QUOTE_OFFER_SCREEN, COMPARE_PLAN_SCREEN];
export const invalidateCacheWithUrl = (
screenUrl: string | null | undefined
) => {
return screenUrlCacheList.includes(screenUrl || "");
};
export const screenUrlCacheList = ["gi/insurance_container/pre_quote_journey", "react_native/gi/insurance_container/pre_quote_journey"];
export const shouldInvalidateSavedData = (
cta: CtaData
): boolean => {
cta.parameters?.forEach((item) => {
if (item.key === 'invalidateCache' && item.value === 'true') {
return true;
}
})
return false;
};

View File

@@ -29,10 +29,6 @@ import { getQuoteIdFromCta, getQuoteIdFromScreenMetaData } from "../../utilities
import { updateValueByKeyPath } from "../../utilities/MiscUtils"; import { updateValueByKeyPath } from "../../utilities/MiscUtils";
import { parseValue } from "../../utilities/SerializerUtil"; import { parseValue } from "../../utilities/SerializerUtil";
import { WidgetActionTypes } from "./WidgetActionTypes"; import { WidgetActionTypes } from "./WidgetActionTypes";
import {
getStringPreference,
setStringPreference,
} from "../../utilities/SharedPreferenceUtils";
const WidgetActionHandler = { const WidgetActionHandler = {
handleWidgetAction: ( handleWidgetAction: (
@@ -136,32 +132,14 @@ const WidgetActionHandler = {
case WidgetActionTypes.PATCH_QUOTE_V2: { case WidgetActionTypes.PATCH_QUOTE_V2: {
let quoteId = getQuoteIdFromCta(ctaData) ?? getQuoteIdFromScreenMetaData(screenData?.screenMetaData); let quoteId = getQuoteIdFromCta(ctaData) ?? getQuoteIdFromScreenMetaData(screenData?.screenMetaData);
const requestData: SumInsuredRequestData = widgetMetaData.data; const requestData: SumInsuredRequestData = widgetMetaData.data;
if (!quoteId) { return updateSumInsuredData(requestData, quoteId!!)
getQuoteIdFromCache().then((value) => { .then((response) => {})
if (!!value) { .catch((error) => {
quoteId = value; const errorEvent: AnalyticsEvent = {
return updateSumInsuredData(requestData, quoteId!!) name: AnalyticsEventNameConstants.PATCH_QUOTE_V2
.then((response) => {}) };
.catch((error) => { sendAsAnalyticsEvent(errorEvent);
const errorEvent: AnalyticsEvent = {
name: AnalyticsEventNameConstants.PATCH_QUOTE_V2
};
sendAsAnalyticsEvent(errorEvent);
});
}
return;
}); });
return;
} else {
return updateSumInsuredData(requestData, quoteId!!)
.then((response) => {})
.catch((error) => {
const errorEvent: AnalyticsEvent = {
name: AnalyticsEventNameConstants.PATCH_QUOTE_V2
};
sendAsAnalyticsEvent(errorEvent);
});
}
} }
case WidgetActionTypes.FINAL_PATCH_CALL: { case WidgetActionTypes.FINAL_PATCH_CALL: {
@@ -169,7 +147,6 @@ const WidgetActionHandler = {
...screenData, ...screenData,
screenState: ScreenState.OVERLAY, screenState: ScreenState.OVERLAY,
}); });
invalidatePostApiData();
let quoteId = getQuoteIdFromCta(ctaData) ?? getQuoteIdFromScreenMetaData(screenData?.screenMetaData); let quoteId = getQuoteIdFromCta(ctaData) ?? getQuoteIdFromScreenMetaData(screenData?.screenMetaData);
const requestData: SumInsuredRequestData = ( const requestData: SumInsuredRequestData = (
widgetMetaData?.data as FinalPatchCallRequestBody widgetMetaData?.data as FinalPatchCallRequestBody
@@ -177,27 +154,6 @@ const WidgetActionHandler = {
const nextPageCta: CtaData = ( const nextPageCta: CtaData = (
widgetMetaData?.data as FinalPatchCallRequestBody widgetMetaData?.data as FinalPatchCallRequestBody
).nextPageCta; ).nextPageCta;
if (!quoteId) {
getQuoteIdFromCache().then((value) => {
if (!!value) {
quoteId = value;
return updateSumInsuredData(requestData, quoteId!!)
.then((response) => {
handleResponseData(nextPageCta, setScreenData, screenData);
})
.catch((error) => {
handleErrorData(
error,
setScreenData,
widgetMetaData,
AnalyticsMethodNameConstant.FINAL_PATCH_CALL,
screenData
);
});
}
return;
});
} else {
return updateSumInsuredData(requestData, quoteId!!) return updateSumInsuredData(requestData, quoteId!!)
.then((response) => { .then((response) => {
handleResponseData(nextPageCta, setScreenData, screenData); handleResponseData(nextPageCta, setScreenData, screenData);
@@ -211,8 +167,6 @@ const WidgetActionHandler = {
screenData screenData
); );
}); });
}
return;
} }
case WidgetActionTypes.SHOW_LOADER: { case WidgetActionTypes.SHOW_LOADER: {
@@ -280,14 +234,6 @@ const WidgetActionHandler = {
}, },
}; };
const getQuoteIdFromCache = async () => {
return await getStringPreference("QUOTE_ID", "string");
};
const invalidatePostApiData = () => {
return setStringPreference("POST_API_CALLED", "false");
};
const handleResponseData = ( const handleResponseData = (
nextPageCta: CtaData, nextPageCta: CtaData,
setScreenData: Dispatch<SetStateAction<ScreenData | null>>, setScreenData: Dispatch<SetStateAction<ScreenData | null>>,

View File

@@ -9,11 +9,6 @@ import { ModalView } from "../../App/common/interface/modals/ModalView";
import { GetModalView } from "../../App/common/modals/modalViewResolver"; import { GetModalView } from "../../App/common/modals/modalViewResolver";
import { NativeDeeplinkNavigatorModule } from "../../App/common/native-module/NativeModules"; import { NativeDeeplinkNavigatorModule } from "../../App/common/native-module/NativeModules";
import styles from "../../App/common/styles/BaseBottomSheetComponentStyles"; import styles from "../../App/common/styles/BaseBottomSheetComponentStyles";
import {
invalidateCacheWithUrl,
shouldInvalidateSavedData,
} from "../../App/common/utilities/CacheUtils";
import { setStringPreference } from "../../App/common/utilities/SharedPreferenceUtils";
import WidgetActionHandler from "../../App/common/widgets/widget-actions/WidgetActionHandler"; import WidgetActionHandler from "../../App/common/widgets/widget-actions/WidgetActionHandler";
import { WidgetActionTypes } from "../../App/common/widgets/widget-actions/WidgetActionTypes"; import { WidgetActionTypes } from "../../App/common/widgets/widget-actions/WidgetActionTypes";
@@ -40,14 +35,7 @@ const BaseBottomSheetComponent = ({
}, BOTTOMSHEET_ANIMATION_DURATION); }, BOTTOMSHEET_ANIMATION_DURATION);
}; };
const invalidatePostApiData = () => {
return setStringPreference("POST_API_CALLED", "false");
};
const handleModalClick = (cta: CtaData) => { const handleModalClick = (cta: CtaData) => {
if (invalidateCacheWithUrl(cta.url) || shouldInvalidateSavedData(cta)) {
invalidatePostApiData();
}
switch (cta?.type) { switch (cta?.type) {
case CtaType.DISMISS_MODAL: case CtaType.DISMISS_MODAL:
if (!!cta?.analyticsEventProperties) { if (!!cta?.analyticsEventProperties) {

View File

@@ -3,7 +3,7 @@ import codePush from "react-native-code-push";
import App from "./App"; import App from "./App";
let codePushOptions = { let codePushOptions = {
installMode: codePush.InstallMode.IMMEDIATE, installMode: codePush.InstallMode.ON_NEXT_RESTART,
checkFrequency: codePush.CheckFrequency.MANUAL, checkFrequency: codePush.CheckFrequency.MANUAL,
}; };