Skip to content

Commit

Permalink
fix(chat): fix the infinite loader for "New conversation" (Issue #2358)…
Browse files Browse the repository at this point in the history
… (#2359)
  • Loading branch information
IlyaBondar authored Oct 11, 2024
1 parent 9324e3e commit 838fc31
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions apps/chat/src/store/conversations/conversations.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 838fc31

Please sign in to comment.