From 0d6d68dd3f07574144f47b758207d0e42c2be999 Mon Sep 17 00:00:00 2001 From: Loren Posen Date: Wed, 6 Nov 2024 16:32:29 -0800 Subject: [PATCH 1/4] Removed duplicate `IterableAction` and `IterableActionContext` --- src/Iterable.ts | 37 +--------------------------------- src/IterableAction.ts | 4 ++++ src/__tests__/Iterable.test.ts | 16 +++++++++------ 3 files changed, 15 insertions(+), 42 deletions(-) diff --git a/src/Iterable.ts b/src/Iterable.ts index a318b1198..f4b56819f 100644 --- a/src/Iterable.ts +++ b/src/Iterable.ts @@ -19,6 +19,7 @@ import IterableInAppManager from './IterableInAppManager'; import IterableInAppMessage from './IterableInAppMessage'; import IterableConfig, { AuthResponse } from './IterableConfig'; import { IterableLogger } from './IterableLogger'; +import type IterableAction from './IterableAction'; const RNIterableAPI = NativeModules.RNIterableAPI; const RNEventEmitter = new NativeEventEmitter(RNIterableAPI); @@ -46,42 +47,6 @@ export enum IterableLogLevel { error = 3, } -/** - * IterableAction represents an action defined as a response to user events. - * It is currently used in push notification actions (open push & action buttons). - */ -export class IterableAction { - type: string; - data?: string; - userInput?: string; - - constructor(type: string, data?: string, userInput?: string) { - this.type = type; - this.data = data; - this.userInput = userInput; - } - - static fromDict(dict: any): IterableAction { - return new IterableAction(dict.type, dict.data, dict.userInput); - } -} - -export class IterableActionContext { - action: IterableAction; - source: IterableActionSource; - - constructor(action: IterableAction, source: IterableActionSource) { - this.action = action; - this.source = source; - } - - static fromDict(dict: any): IterableActionContext { - const action = IterableAction.fromDict(dict.action); - const source = dict.source as IterableActionSource; - return new IterableActionContext(action, source); - } -} - export class IterableAttributionInfo { campaignId: number; templateId: number; diff --git a/src/IterableAction.ts b/src/IterableAction.ts index c00daadbe..a9ef6fbf0 100644 --- a/src/IterableAction.ts +++ b/src/IterableAction.ts @@ -1,3 +1,7 @@ +/** + * IterableAction represents an action defined as a response to user events. + * It is currently used in push notification actions (open push & action buttons). + */ export class IterableAction { type: string; data?: string; diff --git a/src/__tests__/Iterable.test.ts b/src/__tests__/Iterable.test.ts index bfc0c52f8..e4b4fcc8c 100644 --- a/src/__tests__/Iterable.test.ts +++ b/src/__tests__/Iterable.test.ts @@ -1,21 +1,25 @@ import { NativeEventEmitter } from 'react-native'; -import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI'; import { MockLinking } from '../__mocks__/MockLinking'; +import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI'; import { TestHelper } from './TestHelper'; // import from the same location that consumers import from -import { Iterable, IterableConfig, IterableLogLevel } from '../index'; import { - IterableAttributionInfo, - IterableCommerceItem, + Iterable, + IterableAction, IterableActionContext, + IterableConfig, + IterableLogLevel, +} from '../index'; +import { EventName, - IterableAction, IterableActionSource, + IterableAttributionInfo, + IterableCommerceItem, } from '../Iterable'; -import { IterableLogger } from '../IterableLogger'; import { IterableDataRegion } from '../IterableDataRegion'; +import { IterableLogger } from '../IterableLogger'; describe('Iterable', () => { beforeEach(() => { From 09329d8a85510eeb61d157fce1aff8f076c8c1f4 Mon Sep 17 00:00:00 2001 From: Loren Posen Date: Wed, 6 Nov 2024 16:37:03 -0800 Subject: [PATCH 2/4] Removed duplicate `IterableActionSource` --- src/Iterable.ts | 23 ++++++++--------------- src/IterableAction.ts | 27 +++++++++++++++------------ src/IterableInboxMessageDisplay.tsx | 8 ++++++-- src/__tests__/Iterable.test.ts | 2 +- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Iterable.ts b/src/Iterable.ts index f4b56819f..a5c946dc4 100644 --- a/src/Iterable.ts +++ b/src/Iterable.ts @@ -3,36 +3,29 @@ */ import { - NativeModules, - NativeEventEmitter, Linking, + NativeEventEmitter, + NativeModules, Platform, } from 'react-native'; import { - IterableInAppLocation, + type IterableAction, + type IterableActionContext, +} from './IterableAction'; +import IterableConfig, { AuthResponse } from './IterableConfig'; +import { IterableInAppCloseSource, IterableInAppDeleteSource, + IterableInAppLocation, } from './IterableInAppClasses'; - import IterableInAppManager from './IterableInAppManager'; import IterableInAppMessage from './IterableInAppMessage'; -import IterableConfig, { AuthResponse } from './IterableConfig'; import { IterableLogger } from './IterableLogger'; -import type IterableAction from './IterableAction'; const RNIterableAPI = NativeModules.RNIterableAPI; const RNEventEmitter = new NativeEventEmitter(RNIterableAPI); -/** - * Enum representing the source of IterableAction. - */ -export enum IterableActionSource { - push = 0, - appLink = 1, - inApp = 2, -} - enum AuthResponseCallback { SUCCESS, FAILURE, diff --git a/src/IterableAction.ts b/src/IterableAction.ts index a9ef6fbf0..c7bbb298b 100644 --- a/src/IterableAction.ts +++ b/src/IterableAction.ts @@ -1,3 +1,18 @@ +/** + * Enum representing the source of IterableAction. + */ +export enum IterableActionSource { + push = 0, + appLink = 1, + inApp = 2, +} + +export enum IterableLogLevel { + debug = 1, + info = 2, + error = 3, +} + /** * IterableAction represents an action defined as a response to user events. * It is currently used in push notification actions (open push & action buttons). @@ -34,16 +49,4 @@ export class IterableActionContext { } } -export enum IterableActionSource { - push = 0, - appLink = 1, - inApp = 2, -} - -export enum IterableLogLevel { - debug = 1, - info = 2, - error = 3, -} - export default IterableAction; diff --git a/src/IterableInboxMessageDisplay.tsx b/src/IterableInboxMessageDisplay.tsx index 9e2f9849c..730a1320c 100644 --- a/src/IterableInboxMessageDisplay.tsx +++ b/src/IterableInboxMessageDisplay.tsx @@ -11,8 +11,12 @@ import Icon from 'react-native-vector-icons/Ionicons'; import { WebView } from 'react-native-webview'; import { type InboxRowViewModel } from './InboxRowViewModel'; -import { Iterable, IterableActionSource } from './Iterable'; -import { IterableAction, IterableActionContext } from './IterableAction'; +import { Iterable } from './Iterable'; +import { + IterableAction, + IterableActionContext, + IterableActionSource, +} from './IterableAction'; import { IterableEdgeInsets, IterableHtmlInAppContent, diff --git a/src/__tests__/Iterable.test.ts b/src/__tests__/Iterable.test.ts index e4b4fcc8c..a257c8f0c 100644 --- a/src/__tests__/Iterable.test.ts +++ b/src/__tests__/Iterable.test.ts @@ -9,12 +9,12 @@ import { Iterable, IterableAction, IterableActionContext, + IterableActionSource, IterableConfig, IterableLogLevel, } from '../index'; import { EventName, - IterableActionSource, IterableAttributionInfo, IterableCommerceItem, } from '../Iterable'; From 18e27eace1c9d3f28c077de8e8044f66a9757f7f Mon Sep 17 00:00:00 2001 From: Loren Posen Date: Wed, 6 Nov 2024 16:44:00 -0800 Subject: [PATCH 3/4] Removed duplicate `IterableLogLevel` --- src/Iterable.ts | 14 +------------- src/IterableAction.ts | 3 +++ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Iterable.ts b/src/Iterable.ts index a5c946dc4..2daee5659 100644 --- a/src/Iterable.ts +++ b/src/Iterable.ts @@ -9,10 +9,7 @@ import { Platform, } from 'react-native'; -import { - type IterableAction, - type IterableActionContext, -} from './IterableAction'; +import { IterableAction, IterableActionContext } from './IterableAction'; import IterableConfig, { AuthResponse } from './IterableConfig'; import { IterableInAppCloseSource, @@ -31,15 +28,6 @@ enum AuthResponseCallback { FAILURE, } -/** - * Enum representing what level of logs will Android and iOS project be printing on their consoles respectively. - */ -export enum IterableLogLevel { - debug = 1, - info = 2, - error = 3, -} - export class IterableAttributionInfo { campaignId: number; templateId: number; diff --git a/src/IterableAction.ts b/src/IterableAction.ts index c7bbb298b..7115e8c8a 100644 --- a/src/IterableAction.ts +++ b/src/IterableAction.ts @@ -7,6 +7,9 @@ export enum IterableActionSource { inApp = 2, } +/** + * Enum representing what level of logs will Android and iOS project be printing on their consoles respectively. + */ export enum IterableLogLevel { debug = 1, info = 2, From b326c53a7d42d5711d8d8d82abe43f46bd55649e Mon Sep 17 00:00:00 2001 From: Loren Posen Date: Wed, 6 Nov 2024 17:56:48 -0800 Subject: [PATCH 4/4] Added missing import --- src/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.tsx b/src/index.tsx index 63217e0e4..b40df9825 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -12,6 +12,7 @@ export { export { IterableAction, IterableActionContext, + IterableActionSource, IterableLogLevel, } from './IterableAction'; export { IterableConfig } from './IterableConfig';