From b048e2f1e0da4875b548e1597d766aeea2682ad1 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Tue, 19 Sep 2023 13:23:27 +0200 Subject: [PATCH 1/3] ref: moved Chronos lib to TS and add export type needed in Chronos lib --- src/libs/actions/{Chronos.js => Chronos.ts} | 9 ++------- src/types/onyx/OriginalMessage.ts | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) rename src/libs/actions/{Chronos.js => Chronos.ts} (89%) diff --git a/src/libs/actions/Chronos.js b/src/libs/actions/Chronos.ts similarity index 89% rename from src/libs/actions/Chronos.js rename to src/libs/actions/Chronos.ts index b9c0eed7b354..bf758128714f 100644 --- a/src/libs/actions/Chronos.js +++ b/src/libs/actions/Chronos.ts @@ -3,14 +3,9 @@ import Onyx from 'react-native-onyx'; import CONST from '../../CONST'; import ONYXKEYS from '../../ONYXKEYS'; import * as API from '../API'; +import {ChronosOOOEvent} from '../../types/onyx/OriginalMessage'; -/** - * @param {String} reportID - * @param {String} reportActionID - * @param {String} eventID - * @param {Object[]} events - */ -const removeEvent = (reportID, reportActionID, eventID, events) => { +const removeEvent = (reportID: string, reportActionID: string, eventID: string, events: ChronosOOOEvent[]) => { const optimisticData = [ { onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 8ed25cb286b0..369ff44773ab 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -137,4 +137,4 @@ type OriginalMessage = | OriginalMessagePolicyTask; export default OriginalMessage; -export type {Reaction}; +export type {Reaction, ChronosOOOEvent}; From 50752ff03ce21048f14e88c81f5a7e5200491f48 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Wed, 20 Sep 2023 11:10:34 +0200 Subject: [PATCH 2/3] chore: add TODO comment --- src/libs/actions/Chronos.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Chronos.ts b/src/libs/actions/Chronos.ts index bf758128714f..3e94196dc50a 100644 --- a/src/libs/actions/Chronos.ts +++ b/src/libs/actions/Chronos.ts @@ -1,4 +1,3 @@ -import _ from 'underscore'; import Onyx from 'react-native-onyx'; import CONST from '../../CONST'; import ONYXKEYS from '../../ONYXKEYS'; @@ -14,6 +13,7 @@ const removeEvent = (reportID: string, reportActionID: string, eventID: string, [reportActionID]: { pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, originalMessage: { + // TODO: remove underscore events: _.reject(events, (event) => event.id === eventID), }, }, From 504bf3de89ae97a91ccba99353c56f9957a30c42 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Wed, 20 Sep 2023 14:01:17 +0200 Subject: [PATCH 3/3] fix: switch from underscore to native js --- src/libs/actions/Chronos.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/actions/Chronos.ts b/src/libs/actions/Chronos.ts index 3e94196dc50a..1b46a68a1afe 100644 --- a/src/libs/actions/Chronos.ts +++ b/src/libs/actions/Chronos.ts @@ -13,8 +13,7 @@ const removeEvent = (reportID: string, reportActionID: string, eventID: string, [reportActionID]: { pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, originalMessage: { - // TODO: remove underscore - events: _.reject(events, (event) => event.id === eventID), + events: events.filter((event) => event.id !== eventID), }, }, },