From a08a77580c65b18e1c559a5ff7bb94cf6e6ebc8d Mon Sep 17 00:00:00 2001 From: Michael Cavallaro Date: Mon, 30 Oct 2023 22:17:27 -0600 Subject: [PATCH] fix: android fixes and cleanup --- src/CommandBar.ts | 6 ++++++ src/HelpHubView.tsx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/CommandBar.ts create mode 100644 src/HelpHubView.tsx diff --git a/src/CommandBar.ts b/src/CommandBar.ts new file mode 100644 index 0000000..f771be1 --- /dev/null +++ b/src/CommandBar.ts @@ -0,0 +1,6 @@ +export type CommandBarOptions = { + orgId: string; + userId?: string; + spinnerColor?: string; + launchCode?: string; +}; diff --git a/src/HelpHubView.tsx b/src/HelpHubView.tsx new file mode 100644 index 0000000..7c1ffc4 --- /dev/null +++ b/src/HelpHubView.tsx @@ -0,0 +1,31 @@ +import React, { useEffect } from 'react'; +import { DeviceEventEmitter, requireNativeComponent } from 'react-native'; +import type { CommandBarOptions } from './CommandBar'; +import type { ViewStyle } from 'react-native'; + +export type HelpHubViewProps = { + options: CommandBarOptions; + onFallbackAction?: (action: any) => void; + style?: ViewStyle; +}; + +export const HelpHubViewNative: React.ComponentClass = + requireNativeComponent('HelpHubView'); + +export const HelpHubView: React.FC = (props) => { + useEffect(() => { + const subscription = DeviceEventEmitter.addListener( + 'onFallbackAction', + (action) => { + props.onFallbackAction?.(action); + } + ); + + return () => { + subscription.remove(); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + return ; +};