From 6a86285381622159f3f91239c212945cf52752f4 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Tue, 12 Sep 2023 21:15:30 +0200 Subject: [PATCH] fix: check if waypoint is not null --- src/libs/actions/Transaction.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index 47010ba275b3..16a974db25ff 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -93,9 +93,8 @@ function saveWaypoint(transactionID: string, index: string, waypoint: RecentWayp if (!lodashHas(waypoint, 'lat') || !lodashHas(waypoint, 'lng')) { return; } - const recentWaypointAlreadyExists = recentWaypoints.find((recentWaypoint) => recentWaypoint?.address === waypoint?.address); - if (!recentWaypointAlreadyExists) { + if (!recentWaypointAlreadyExists && waypoint !== null) { const clonedWaypoints = lodashClone(recentWaypoints); clonedWaypoints.unshift(waypoint); Onyx.merge(ONYXKEYS.NVP_RECENT_WAYPOINTS, clonedWaypoints.slice(0, 5)); @@ -108,7 +107,6 @@ function removeWaypoint(transactionID: string, currentIndex: string) { const transaction = allTransactions?.[transactionID] ?? {}; const existingWaypoints = transaction?.comment?.waypoints ?? {}; const totalWaypoints = Object.keys(existingWaypoints).length; - // Prevents removing the starting or ending waypoint but clear the stored address only if there are only two waypoints if (totalWaypoints === 2 && (index === 0 || index === totalWaypoints - 1)) { saveWaypoint(transactionID, index.toString(), null);