@@ -21,54 +21,14 @@ import { Notifications } from './components/notifications';
21
21
import { PrivateRoute , PublicRoutes , getRoutes } from './config/routes' ;
22
22
import { NavigateToDefault } from "./pages/chat/default-chat-route" ;
23
23
import { useAppDispatch , useAppSelector } from "./store/hooks" ;
24
- import { useCallback , useEffect } from "react" ;
25
- import { useUpdateSettingsMutation , useGetAiProvidersLazyQuery } from "./generated/graphql" ;
26
- import { optInUser , optOutUser } from "./config/posthog" ;
27
- import { DatabaseActions } from "./store/database" ;
28
- import { reduxStore } from "./store" ;
24
+ import { useCallback } from "react" ;
25
+ import { useUpdateSettingsMutation } from "./generated/graphql" ;
26
+ import { optInUser , optOutUser } from "./config/posthog" ;
29
27
30
28
export const App = ( ) => {
31
29
const [ updateSettings , ] = useUpdateSettingsMutation ( ) ;
32
30
const darkModeEnabled = useAppSelector ( state => state . global . theme === "dark" ) ;
33
31
const metricsEnabled = useAppSelector ( state => state . settings . metricsEnabled ) ;
34
- const [ getAiProviders , ] = useGetAiProvidersLazyQuery ( ) ;
35
- const dispatch = useAppDispatch ( ) ;
36
-
37
- useEffect ( ( ) => {
38
- getAiProviders ( {
39
- fetchPolicy : "network-only" ,
40
- onCompleted ( data ) {
41
- const aiProviders = data . AIProviders || [ ] ;
42
- const initialModelTypes = reduxStore . getState ( ) . database . modelTypes . filter ( model => {
43
- const existingModel = aiProviders . find ( provider => provider . ProviderId === model . id ) ;
44
- return existingModel != null || ( model . token != null && model . token !== "" ) ;
45
- } ) ;
46
-
47
- // Filter out providers that already exist in modelTypes
48
- const newProviders = aiProviders . filter ( provider =>
49
- ! initialModelTypes . some ( model => model . id === provider . ProviderId )
50
- ) ;
51
-
52
- const finalModelTypes = [
53
- ...newProviders . map ( provider => ( {
54
- id : provider . ProviderId ,
55
- modelType : provider . Type ,
56
- } ) ) ,
57
- ...initialModelTypes
58
- ] ;
59
-
60
- // Check if current model type exists in final model types
61
- const currentModelType = reduxStore . getState ( ) . database . current ;
62
- if ( currentModelType && ! finalModelTypes . some ( model => model . id === currentModelType . id ) ) {
63
- dispatch ( DatabaseActions . setCurrentModelType ( { id : "" } ) ) ;
64
- dispatch ( DatabaseActions . setModels ( [ ] ) ) ;
65
- dispatch ( DatabaseActions . setCurrentModel ( undefined ) ) ;
66
- }
67
-
68
- dispatch ( DatabaseActions . setModelTypes ( finalModelTypes ) ) ;
69
- } ,
70
- } ) ;
71
- } , [ ] ) ;
72
32
73
33
useEffect ( ( ) => {
74
34
if ( metricsEnabled ) {
0 commit comments