Skip to content

Commit 206f135

Browse files
authored
Update app.tsx
1 parent 4bb33e5 commit 206f135

File tree

1 file changed

+3
-43
lines changed

1 file changed

+3
-43
lines changed

frontend/src/app.tsx

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,14 @@ import { Notifications } from './components/notifications';
2121
import { PrivateRoute, PublicRoutes, getRoutes } from './config/routes';
2222
import { NavigateToDefault } from "./pages/chat/default-chat-route";
2323
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";
2927

3028
export const App = () => {
3129
const [updateSettings, ] = useUpdateSettingsMutation();
3230
const darkModeEnabled = useAppSelector(state => state.global.theme === "dark");
3331
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-
}, []);
7232

7333
useEffect(() => {
7434
if (metricsEnabled) {

0 commit comments

Comments
 (0)