import { useEffect } from 'preact/hooks' // Import extracted hooks here for use inside this file import useSeamlyConversation from './use-seamly-conversation' // Export extracted hooks here, // although this is a redundant, it prevents a bazillion code changes for now. // TODO: Remove exports and import them from the correct files export { useElementFocusingById, useFocusIfSeamlyContainedFocus, useSeamlyContainerElement, useSkiplinkTargetFocusing, } from 'ui/hooks/focus-helper-hooks' export { useSeamlyAppContainerClassNames, useSeamlyMessageContainerClassNames, } from './component-helper-hooks' export { useFileUploadMeta, useFileUploads } from './file-upload-hooks' export { useLiveRegion, useSeamlyLiveRegionContext } from './live-region-hooks' export { useSeamlyApiContext, useSeamlyConversationUrl, } from './seamly-api-hooks' export { useOptionButton, useSeamlyOptions } from './seamly-option-hooks' export { useEntryTextLimit, useEvents, useLastMessageEventId, useSeamlyCurrentAgent, useSeamlyHeaderData, useSeamlyIsHistoryLoaded, useSeamlyIsLoading, useSeamlyLayoutMode, useSeamlyParticipant, useSeamlyServiceData, useSeamlyServiceInfo, useSeamlyStateContext, useSeamlyUnreadCount, useSkiplinkElement, useSkiplinkTarget, } from './seamly-state-hooks' export { default as useSeamlyActivityEventHandler } from './use-seamly-activity-event-handler' export { default as useSeamlyChat } from './use-seamly-chat' export { default as useSeamlyCommands } from './use-seamly-commands' export { default as useSeamlyIdleDetachCountdown } from './use-seamly-idle-detach-countdown' export { default as useSeamlyResumeConversationPrompt } from './use-seamly-resume-conversation-prompt' export { useForceUpdate, useGeneratedId } from './utility-hooks' // This hook isn't used within the core // But it is used in implementations // and imported directly from this file // Please do not remove export const useSeamlyEventStream = (nextFn, filterFn) => { const conversation = useSeamlyConversation() useEffect(() => { conversation.onMessage((type, payload) => { if (!filterFn || filterFn({ type, payload })) { nextFn({ type, payload }) } return payload }) }, [nextFn, filterFn, conversation]) }