From 838fc317d683faf76d6d2488938c3aec9a35682f Mon Sep 17 00:00:00 2001 From: Ilya Bondar Date: Fri, 11 Oct 2024 18:03:35 +0200 Subject: [PATCH] fix(chat): fix the infinite loader for "New conversation" (Issue #2358) (#2359) --- .../conversations/conversations.epics.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index 83efe4a4c9..8e5606b9ae 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -372,20 +372,29 @@ const createNewConversationsEpic: AppEpic = (action$, state$) => const models = ModelsSelectors.selectModels(state); return models.filter((i) => i?.id === isolatedModelId); } + const models = ModelsSelectors.selectModels(state); + const recentModels = ModelsSelectors.selectRecentModels(state); if (lastConversation?.model.id) { const lastModelId = lastConversation.model.id; - const models = ModelsSelectors.selectModels(state); - return models.filter((i) => i?.id === lastModelId); + return [ + ...models.filter((i) => i?.id === lastModelId), + ...recentModels, + ...models, + ]; } - return ModelsSelectors.selectRecentModels(state); + return [...recentModels, ...models]; }), - filter((models) => models && models.length > 0), take(1), switchMap((recentModels) => { const model = recentModels[0]; if (!model) { - return EMPTY; + console.error( + 'Creation failed: no models were found for conversation', + ); + return of( + ConversationsActions.setIsActiveConversationRequest(false), + ); } const conversationRootId = getConversationRootId(); const newConversations: Conversation[] = names.map(