|
3 | 3 | * @author Box |
4 | 4 | */ |
5 | 5 | import * as React from 'react'; |
6 | | -import noop from 'lodash/noop'; |
7 | 6 | import { useIntl } from 'react-intl'; |
8 | 7 | import { type QuestionType } from '@box/box-ai-content-answers'; |
9 | 8 | import { RecordActionType } from '@box/box-ai-agent-selector'; |
10 | 9 | import BoxAISidebarContent from './BoxAISidebarContent'; |
| 10 | +import { BoxAISidebarContext } from './context/BoxAISidebarContext'; |
11 | 11 | import { DOCUMENT_SUGGESTED_QUESTIONS, SPREADSHEET_FILE_EXTENSIONS } from '../common/content-answers/constants'; |
12 | 12 |
|
13 | 13 | import messages from '../common/content-answers/messages'; |
14 | 14 |
|
15 | | -export interface BoxAISidebarContextValues { |
16 | | - cache: { encodedSession?: string | null; questions?: QuestionType[] }; |
17 | | - contentName: string; |
18 | | - elementId: string; |
19 | | - fileExtension: string; |
20 | | - isStopResponseEnabled: boolean; |
21 | | - itemSize?: string; |
22 | | - recordAction: (params: RecordActionType) => void; |
23 | | - setCacheValue: (key: 'encodedSession' | 'questions', value: string | null | QuestionType[]) => void; |
24 | | - userInfo: { name: string; avatarURL: string }; |
25 | | -} |
26 | | - |
27 | | -export const BoxAISidebarContext = React.createContext<BoxAISidebarContextValues>({ |
28 | | - cache: null, |
29 | | - contentName: '', |
30 | | - elementId: '', |
31 | | - fileExtension: '', |
32 | | - isStopResponseEnabled: false, |
33 | | - recordAction: noop, |
34 | | - setCacheValue: noop, |
35 | | - userInfo: { name: '', avatarURL: '' }, |
36 | | -}); |
37 | | - |
38 | 15 | export interface BoxAISidebarProps { |
39 | 16 | contentName: string; |
40 | 17 | cache: { encodedSession?: string | null; questions?: QuestionType[] }; |
@@ -107,7 +84,7 @@ const BoxAISidebar = (props: BoxAISidebarProps) => { |
107 | 84 | }, []); |
108 | 85 |
|
109 | 86 | React.useEffect(() => { |
110 | | - document.addEventListener('keydown', handleKeyPress,{ capture: true }); |
| 87 | + document.addEventListener('keydown', handleKeyPress, { capture: true }); |
111 | 88 | return () => { |
112 | 89 | document.removeEventListener('keydown', handleKeyPress, { capture: true }); |
113 | 90 | }; |
|
0 commit comments