@@ -18,7 +18,7 @@ interface ChatState {
1818 chatProfile ?: string ;
1919 chatSettingsInputs : any [ ] ;
2020 chatSettingsDefaultValue : any ;
21- chatSettingsValue : any ;
21+ chatSettingsValue : Record < any , any > ;
2222
2323 setIsAiSpeaking : ( isAiSpeaking : boolean ) => void ;
2424 setAudioConnection : ( audioConnection : 'connecting' | 'on' | 'off' ) => void ;
@@ -42,7 +42,7 @@ interface ChatState {
4242 ) => void ;
4343 setChatProfile : ( chatProfile : string ) => void ;
4444 setChatSettingsInputs : ( chatSettingsInputs : any [ ] ) => void ;
45- setChatSettingsValue : ( chatSettingsValue : any ) => void ;
45+ setChatSettingsValue : ( chatSettingsValue : Record < any , any > ) => void ;
4646 resetChatSettingsInputs : ( ) => void ;
4747 resetChatSettingsValue : ( ) => void ;
4848}
@@ -110,13 +110,13 @@ export const useChatStore = create<ChatState>((set, get) => ({
110110 }
111111} ) ) ;
112112
113- // useChatStore.subscribe((state, prevState ) => {
114- // const chatSettingsDefaultValue = state.chatSettingsInputs.reduce(
115- // (form: { [key: string]: any }, input: any) => (
116- // (form[input.id] = input.initial), form
117- // ),
118- // {}
119- // );
120- //
121- // useChatStore.setState({chatSettingsDefaultValue });
122- // })
113+ useChatStore . subscribe ( ( state ) => {
114+ const chatSettingsDefaultValue = state . chatSettingsInputs . reduce (
115+ ( form : { [ key : string ] : any } , input : any ) => (
116+ ( form [ input . id ] = input . initial ) , form
117+ ) ,
118+ { }
119+ ) ;
120+
121+ useChatStore . setState ( { chatSettingsDefaultValue } ) ;
122+ } ) ;
0 commit comments