TP-69871 | longhorn block pr fixes

This commit is contained in:
varnit-goyal_navi
2024-08-26 16:47:07 +05:30
parent 1b5b4bf95b
commit 63a717fbcc
4 changed files with 30 additions and 16 deletions

View File

@@ -73,6 +73,7 @@ import { initialize } from 'react-native-clarity';
import { getPermissionsToRequest } from '@components/utlis/PermissionUtils';
import { syncToLonghorn } from '../miniModules/callingAgents/screens/homeScreen/action';
import { updateImageUploadComponent } from '@components/form/services/formComponents';
import React from "react";
export enum FOREGROUND_TASKS {
GEOLOCATION = 'GEOLOCATION',
@@ -275,7 +276,7 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
const taskSyncToLonghorn = async () => {
const allPermissionsGranted = await checkPermissions();
await syncToLonghorn(allPermissionsGranted, agentId, appVersion);
await syncToLonghorn({allPermissionsGranted, agentId, appVersion, isSyncToastEnabled: false});
};
const tasks: IForegroundTask[] = [
@@ -346,12 +347,6 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
delay: 3 * MILLISECONDS_IN_A_MINUTE, // 3 minutes
onLoop: true,
},
{
taskId: FOREGROUND_TASKS.COSMOS_SYNC_WITH_LONGHORN,
task: taskSyncToLonghorn,
delay: 5 * MILLISECONDS_IN_A_SECOND,
onLoop: true,
}
];
if (!isTeamLead) {
@@ -362,7 +357,6 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
onLoop: true,
});
}
const handleDataSync = () => {
if (!isOnline) {
return;
@@ -382,6 +376,17 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
});
}
if(GLOBAL?.BUILD_FLAVOUR === 'callingAgents') {
tasks.push({
taskId: FOREGROUND_TASKS.COSMOS_SYNC_WITH_LONGHORN,
task: taskSyncToLonghorn,
delay: 5 * MILLISECONDS_IN_A_SECOND,
onLoop: true,
});
}
const userActivityUpdateOnBackground = async () => {
const foregroundTimestamp = await getItem(StorageKeys.APP_FOREGROUND_TIMESTAMP);
const backgroundTimestamp = await getItem(StorageKeys.APP_BACKGROUND_TIMESTAMP);
@@ -427,6 +432,7 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
MS_CLARITY_PROJECT_ID &&
!GLOBAL.MS_CLARITY_INITIALIZED &&
msClarityResponse &&
//@ts-expect-error - The configuration will change at runtime
ENV === 'prod'
) {
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.MS_CLARITY_INITIALIZED, {
@@ -464,8 +470,7 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
}, []);
useEffect(() => {
let appStateSubscription: NativeEventSubscription;
appStateSubscription = AppState.addEventListener('change', handleAppStateChange);
const appStateSubscription = AppState.addEventListener('change', handleAppStateChange);
CosmosForegroundService.start(tasks);
return () => {
appStateSubscription?.remove();