TP-46779 | performance optimisations
This commit is contained in:
@@ -22,6 +22,6 @@
|
||||
"react-native"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/strict-boolean-expressions": 1
|
||||
"@typescript-eslint/strict-boolean-expressions": 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
"@react-native-firebase/database": "16.4.6",
|
||||
"@react-native-firebase/firestore": "16.5.0",
|
||||
"@react-native-firebase/messaging": "17.4.0",
|
||||
"@react-native-firebase/perf": "^18.6.0",
|
||||
"@react-native-firebase/perf": "^16.5.2",
|
||||
"@react-native-firebase/remote-config": "16.4.6",
|
||||
"@react-native-google-signin/google-signin": "9.0.2",
|
||||
"@react-navigation/bottom-tabs": "6.5.5",
|
||||
|
||||
@@ -4,6 +4,7 @@ import auth from '@react-native-firebase/auth';
|
||||
import { setFeedbackFilterTemplate } from '@reducers/feedbackFiltersSlice';
|
||||
import perf from '@react-native-firebase/perf';
|
||||
import { InteractionManager } from 'react-native';
|
||||
import chunks from 'lodash.chunk';
|
||||
import { type RootState } from '../store/store';
|
||||
import { useAppDispatch, useAppSelector } from '.';
|
||||
import { setLoading, updateCaseDetailsFirestore } from '../reducer/allCasesSlice';
|
||||
@@ -18,7 +19,6 @@ import { ToastMessages } from '../screens/allCases/constants';
|
||||
import { setForceUninstallData } from '../reducer/metadataSlice';
|
||||
import { logError } from '../components/utlis/errorUtils';
|
||||
import { type GenericFunctionArgs } from '../common/GenericTypes';
|
||||
import chunks from 'lodash.chunk';
|
||||
|
||||
export interface CaseUpdates {
|
||||
updateType: string;
|
||||
@@ -31,9 +31,7 @@ export const loggedOutCurrentUser = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const isUserSignedIn = () => {
|
||||
return auth().currentUser ? true : false;
|
||||
};
|
||||
const isUserSignedIn = () => !!auth().currentUser;
|
||||
|
||||
const useFirestoreUpdates = () => {
|
||||
const {
|
||||
@@ -113,16 +111,24 @@ const useFirestoreUpdates = () => {
|
||||
const isInitialLoad = casesList.length === 0;
|
||||
await trace.stop();
|
||||
const casesChunks = chunks(caseUpdates, 5);
|
||||
casesChunks.forEach((chunk) => {
|
||||
casesChunks.forEach((chunk, index) => {
|
||||
InteractionManager.runAfterInteractions(() => {
|
||||
dispatch(
|
||||
updateCaseDetailsFirestore({
|
||||
caseUpdates: chunk,
|
||||
isInitialLoad,
|
||||
isVisitPlanLocked: lockRef?.current?.visitPlanStatus === VisitPlanStatus.LOCKED,
|
||||
selectedAgent,
|
||||
})
|
||||
);
|
||||
requestAnimationFrame(()=>{
|
||||
InteractionManager.runAfterInteractions(() => {
|
||||
dispatch(
|
||||
updateCaseDetailsFirestore({
|
||||
caseUpdates: chunk,
|
||||
isInitialLoad,
|
||||
isVisitPlanLocked: lockRef?.current?.visitPlanStatus === VisitPlanStatus.LOCKED,
|
||||
selectedAgent,
|
||||
chunkIndex:index,
|
||||
totalChunks: casesChunks.length
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
!isInitialLoad && showCaseUpdationToast(newlyAddedCases, deletedCases);
|
||||
|
||||
@@ -259,7 +259,7 @@ const allCasesSlice = createSlice({
|
||||
state.loading = action.payload;
|
||||
},
|
||||
updateCaseDetailsFirestore: (state, action) => {
|
||||
const { caseUpdates, isInitialLoad, isVisitPlanLocked, selectedAgent } = action.payload as {
|
||||
const { caseUpdates, isInitialLoad, isVisitPlanLocked, selectedAgent, chunkIndex, totalChunks } = action.payload as {
|
||||
caseUpdates: CaseUpdates[];
|
||||
isInitialLoad: boolean;
|
||||
isVisitPlanLocked: boolean;
|
||||
|
||||
@@ -119,13 +119,10 @@ const CasesList: React.FC<ICasesList> = ({
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(async () => {
|
||||
const trace = await perf().startTrace(getCurrentScreen()?.name);
|
||||
useCallback( () => {
|
||||
firePageLoadEvent();
|
||||
return () => {
|
||||
trace.stop();
|
||||
};
|
||||
}, [])
|
||||
);
|
||||
|
||||
|
||||
@@ -69,34 +69,34 @@ const ProtectedRouter = () => {
|
||||
|
||||
// Gets unified data for new visit plan cases
|
||||
// TODO: Move this to another place
|
||||
useEffect(() => {
|
||||
if (isTeamLead) {
|
||||
return;
|
||||
}
|
||||
if (newVisitedCases?.length) {
|
||||
const loanAccountNumbers: string[] = [];
|
||||
newVisitedCases.forEach((caseId) => {
|
||||
const { loanAccountNumber } = caseDetails[caseId];
|
||||
if (!loanAccountNumber) {
|
||||
return;
|
||||
}
|
||||
loanAccountNumbers.push(loanAccountNumber);
|
||||
});
|
||||
if (loanAccountNumbers.length) {
|
||||
const { EMI_SCHEDULE, REPAYMENTS, ADDRESS_AND_GEOLOCATIONS, FEEDBACKS } =
|
||||
UnifiedCaseDetailsTypes;
|
||||
dispatch(
|
||||
getCaseUnifiedData(loanAccountNumbers, [
|
||||
EMI_SCHEDULE,
|
||||
REPAYMENTS,
|
||||
ADDRESS_AND_GEOLOCATIONS,
|
||||
FEEDBACKS,
|
||||
])
|
||||
);
|
||||
}
|
||||
dispatch(resetNewVisitedCases());
|
||||
}
|
||||
}, [newVisitedCases]);
|
||||
// useEffect(() => {
|
||||
// if (isTeamLead) {
|
||||
// return;
|
||||
// }
|
||||
// if (newVisitedCases?.length) {
|
||||
// const loanAccountNumbers: string[] = [];
|
||||
// newVisitedCases.forEach((caseId) => {
|
||||
// const { loanAccountNumber } = caseDetails[caseId];
|
||||
// if (!loanAccountNumber) {
|
||||
// return;
|
||||
// }
|
||||
// loanAccountNumbers.push(loanAccountNumber);
|
||||
// });
|
||||
// if (loanAccountNumbers.length) {
|
||||
// const { EMI_SCHEDULE, REPAYMENTS, ADDRESS_AND_GEOLOCATIONS, FEEDBACKS } =
|
||||
// UnifiedCaseDetailsTypes;
|
||||
// dispatch(
|
||||
// getCaseUnifiedData(loanAccountNumbers, [
|
||||
// EMI_SCHEDULE,
|
||||
// REPAYMENTS,
|
||||
// ADDRESS_AND_GEOLOCATIONS,
|
||||
// FEEDBACKS,
|
||||
// ])
|
||||
// );
|
||||
// }
|
||||
// dispatch(resetNewVisitedCases());
|
||||
// }
|
||||
// }, [newVisitedCases]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOnline) {
|
||||
|
||||
10
yarn.lock
10
yarn.lock
@@ -1674,10 +1674,12 @@
|
||||
resolved "https://registry.yarnpkg.com/@react-native-firebase/messaging/-/messaging-17.4.0.tgz#9e1df987183d0ca367d0922a14b14b7a53a140cf"
|
||||
integrity sha512-RSiBBfyJ3K9G6TQfZc09XaGpxB9xlP5m9DYkqjbNIqnnTiahF90770lTAS65L1Ha78vCwVO2swIlk32XbcMcMQ==
|
||||
|
||||
"@react-native-firebase/perf@^18.6.0":
|
||||
version "18.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@react-native-firebase/perf/-/perf-18.6.0.tgz#6edc13cbf770ed378ccbe1dadead40167bbf87d9"
|
||||
integrity sha512-hVtG0mAs4LBSobBG4DQ0vtJOEvQRGg9+oVQUDb5VgWKW21IAfljEpeFo831xoolpaE/Oyz33tmyrBgqPKKzZ+w==
|
||||
"@react-native-firebase/perf@^16.5.2":
|
||||
version "16.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@react-native-firebase/perf/-/perf-16.7.0.tgz#bf081d4f9aae21337455aa670756eba26d9fc914"
|
||||
integrity sha512-d3fdbKaIkl2NudRQPvS3RCtM0/IAWGgn+6UKkJZHB6XLmn34AIcfamiAbmFgLdyxmBnZforQiZXM0OOL9uYoUA==
|
||||
dependencies:
|
||||
"@expo/config-plugins" "^5.0.4"
|
||||
|
||||
"@react-native-firebase/remote-config@16.4.6":
|
||||
version "16.4.6"
|
||||
|
||||
Reference in New Issue
Block a user