TP-61032 | Alfred Screen Name Filter support (#10347)

This commit is contained in:
Kshitij Pramod Ghongadi
2024-04-07 20:25:37 +05:30
committed by GitHub
parent 45f81a3ee1
commit fc98c73316
3 changed files with 19 additions and 5 deletions

View File

@@ -1,4 +1,3 @@
import { useFocusEffect } from "@react-navigation/native";
import { isEqual } from "lodash";
import React, { useEffect, useMemo, useState } from "react";
import { View } from "react-native";
@@ -7,21 +6,25 @@ import { commonStyles } from "../../Container/Navi-Insurance/Styles";
import { ActionMetaData, GenericActionPayload } from "../actions/GenericAction";
import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent";
import { useBottomSheet } from "../hooks/useBottomSheet";
import { logToSentry } from "../hooks/useSentryLogging";
import { CtaData } from "../interface";
import { ModalView } from "../interface/modals/ModalView";
import { ScreenData } from "../interface/widgets/screenData/ScreenData";
import { Router } from "../navigator/NavigationRouter";
import { updateCtaData } from "../redux/screens/screenActionCreators";
import { setCurrentScreenName } from "../utilities/AlfredUtils";
import {
getCacheKey,
getScreenDataFromCache,
isScreenWhiteListedForCaching,
saveScreenDataInCache,
} from "../utilities/CacheUtils";
import { getScreenNameFromCtaData } from "../utilities/MiscUtils";
import {
getScreenMapperNameFromCtaData,
getScreenNameFromCtaData,
} from "../utilities/MiscUtils";
import { WidgetActionTypes } from "../widgets/widget-actions/WidgetActionTypes";
import { ScreenMapper } from "./screen-mappers/ScreenMapper";
import { logToSentry } from "../hooks/useSentryLogging";
const BaseScreen: React.FC<{ navigation: any; route: any }> = ({
navigation,
@@ -103,7 +106,6 @@ const BaseScreen: React.FC<{ navigation: any; route: any }> = ({
}
}, [route.params.ctaData, screenState]);
const { bottomsheet, addBottomSheet } = useBottomSheet();
const handleActions = (actionPayload?: GenericActionPayload) => {
@@ -134,6 +136,11 @@ const BaseScreen: React.FC<{ navigation: any; route: any }> = ({
});
};
const MemoizedScreenMapper = useMemo(() => {
const secondIdentifier = getScreenMapperNameFromCtaData(cta);
setCurrentScreenName(
"RN_" + secondIdentifier?.toUpperCase() + "_" + screenName
);
return (
<View style={commonStyles.flex_1}>
{ScreenMapper.getScreenMapper(cta, screenData, handleActions)}
@@ -158,4 +165,4 @@ export enum ScreenState {
OVERLAY,
}
export default BaseScreen;
export default BaseScreen;

View File

@@ -4,3 +4,5 @@ export const setBottomSheetView = (id: number | null) =>
AlfredModuleConnector.setBottomSheetView(id!!);
export const clearBottomSheet = () => AlfredModuleConnector.clearBottomSheet();
export const setCurrentScreenName = (screenName: string) => AlfredModuleConnector.setCurrentScreenName(screenName);

View File

@@ -37,4 +37,9 @@ class AlfredModuleConnector internal constructor(context: ReactApplicationContex
fun clearBottomSheet() {
AlfredManager.clearBottomSheetView()
}
@ReactMethod
fun setCurrentScreenName(screenName: String) {
AlfredManager.setCurrentScreenName(screenName)
}
}