-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change in embedded api params * Update EmbeddedMsgs.tsx (#263) * Update index.tsx (#264) * Update index.tsx (#265) * Update index.tsx (#266) * Update embeddedManager.ts (#267) * Update index.ts (#268) * Update events.schema.ts (#270) * Update types.ts (#271) * Update yarn.lock (#272) * Create IterableActionRunner.ts (#274) * Update embeddedManager.ts (#276) * Update types.ts (#277) * Resolve build fail issue (#289) * Resolve merge conflicts
- Loading branch information
1 parent
47ab4f4
commit 198ecf6
Showing
9 changed files
with
204 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
export enum IterableActionSource { | ||
PUSH = 'PUSH', | ||
APP_LINK = 'APP_LINK', | ||
IN_APP = 'IN_APP', | ||
EMBEDDED = 'EMBEDDED' | ||
} | ||
|
||
export interface IterableAction { | ||
type: string; | ||
data: string; | ||
} | ||
|
||
export interface IterableActionContext { | ||
action: IterableAction; | ||
source: IterableActionSource; | ||
} | ||
|
||
interface IterableConfig { | ||
urlHandler?: { | ||
handleIterableURL( | ||
uri: string, | ||
actionContext: IterableActionContext | ||
): boolean; | ||
}; | ||
customActionHandler?: { | ||
handleIterableCustomAction( | ||
action: IterableAction, | ||
actionContext: IterableActionContext | ||
): boolean; | ||
}; | ||
} | ||
|
||
class IterableActionRunnerConfig { | ||
static config: IterableConfig = {}; | ||
} | ||
|
||
class IterableActionRunnerImpl { | ||
|
||
executeAction( | ||
context: any, | ||
action: IterableAction | null, | ||
source: IterableActionSource | ||
): boolean { | ||
if (action === null) { | ||
return false; | ||
} | ||
|
||
const actionContext: IterableActionContext = { action, source }; | ||
|
||
if (action.type === 'openUrl') { | ||
return this.openUri(action.data, actionContext); | ||
} else { | ||
return this.callCustomActionIfSpecified(action, actionContext); | ||
} | ||
} | ||
|
||
private openUri(uri: string, actionContext: IterableActionContext): boolean { | ||
if (IterableActionRunnerConfig.config.urlHandler) { | ||
if ( | ||
IterableActionRunnerConfig.config.urlHandler.handleIterableURL( | ||
uri, | ||
actionContext | ||
) | ||
) { | ||
return true; | ||
} | ||
} | ||
|
||
window.open(uri, '_blank'); | ||
|
||
return true; | ||
} | ||
|
||
private callCustomActionIfSpecified( | ||
action: IterableAction, | ||
actionContext: IterableActionContext | ||
): boolean { | ||
if (action.type && action.type !== '') { | ||
if (IterableActionRunnerConfig.config.customActionHandler) { | ||
return IterableActionRunnerConfig.config.customActionHandler.handleIterableCustomAction( | ||
action, | ||
actionContext | ||
); | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
IterableActionRunnerConfig.config = { | ||
urlHandler: { | ||
handleIterableURL( | ||
uri: string, | ||
actionContext: IterableActionContext | ||
): boolean { | ||
global.open(uri, '_blank', 'noopener,noreferrer'); | ||
return true; | ||
} | ||
}, | ||
customActionHandler: { | ||
handleIterableCustomAction( | ||
action: IterableAction, | ||
actionContext: IterableActionContext | ||
): boolean { | ||
let uri = ''; | ||
if (action.type.startsWith('action://')) { | ||
uri = action.type.replace('action://', ''); | ||
} else if (action.type.startsWith('iterable://')) { | ||
uri = action.type.replace('iterable://', ''); | ||
} | ||
|
||
global.open(uri, '_blank', 'noopener,noreferrer'); | ||
return true; | ||
} | ||
} | ||
}; | ||
|
||
export class IterableActionRunner extends IterableActionRunnerImpl { | ||
static config = IterableActionRunnerConfig.config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters