Skip to content

Commit

Permalink
fix loop issue on fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahbaa5 committed Aug 6, 2023
1 parent 0a56cff commit 33a36ed
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,37 @@ function App()
const setApiKey = useStore((state) => state.setApiKey);
const setCurrentChatIndex = useStore((state) => state.setCurrentChatIndex);

(async () =>
if (!isInitialized)
{
const initalizeModelDataResult = await initaliseModelData();
if (!initalizeModelDataResult)
(async () =>
{
alert("Failed getting model data from OpenRouterAI API.\nTry restarting or refreshing.\n\n(Currently default models will be shown that may include deprecated model or invalid information.)");
}
var fixDefaultModels = true;

const localChats = useStore.getState().chats;
if (localChats && localChats.length > 0)
{
for (var i = 0; i < localChats.length; i++)
const initalizeModelDataResult = await initaliseModelData();
if (initalizeModelDataResult)
{
const chat: ChatInterface = localChats[i];
if (!modelOptions.includes(chat.config.model))
fixDefaultModels = confirm("Failed getting model data from OpenRouterAI API.\nTry restarting or refreshing.\n\n(Currently default models will be shown that may include deprecated model or invalid information.)\n\nIf you proceed to continue, chats with the model that is not in the current list will be changed to the default model.");
}

if (fixDefaultModels)
{
const localChats = useStore.getState().chats;
if (localChats && localChats.length > 0)
{
chat.config.model = defaultModel;
for (var i = 0; i < localChats.length; i++)
{
const chat: ChatInterface = localChats[i];
if (!modelOptions.includes(chat.config.model))
{
chat.config.model = defaultModel;
}
}
}
}
}
}

setIsInitialized(true);
})();
setIsInitialized(true);
})();
}

useEffect(() =>
{
Expand Down

0 comments on commit 33a36ed

Please sign in to comment.