Skip to content

Commit

Permalink
πŸ› fix: fix topic title not auto generate (#2114)
Browse files Browse the repository at this point in the history
* πŸ› fix: fix topic auto gen

* βœ… test: fix test

* 🎨 chore: improve code
  • Loading branch information
arvinxx authored Apr 20, 2024
1 parent 1176948 commit 5979de3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/store/chat/slices/topic/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ describe('topic action', () => {
});

// Check if mutate has been called with the active session ID
expect(mutate).toHaveBeenCalledWith(['SWR_USE_FETCH_TOPIC', activeId], undefined, {
populateCache: false,
});
expect(mutate).toHaveBeenCalledWith(['SWR_USE_FETCH_TOPIC', activeId]);
});

it('should handle errors during refreshing topics', async () => {
Expand Down
15 changes: 5 additions & 10 deletions src/store/chat/slices/topic/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { StateCreator } from 'zustand/vanilla';
import { chainSummaryTitle } from '@/chains/summaryTitle';
import { LOADING_FLAT } from '@/const/message';
import { TraceNameMap } from '@/const/trace';
import { SWRefreshMethod, useClientDataSWR } from '@/libs/swr';
import { useClientDataSWR } from '@/libs/swr';
import { chatService } from '@/services/chat';
import { messageService } from '@/services/message';
import { topicService } from '@/services/topic';
Expand All @@ -29,7 +29,7 @@ const SWR_USE_SEARCH_TOPIC = 'SWR_USE_SEARCH_TOPIC';
export interface ChatTopicAction {
favoriteTopic: (id: string, favState: boolean) => Promise<void>;
openNewTopicOrSaveTopic: () => Promise<void>;
refreshTopic: SWRefreshMethod<ChatTopic[]>;
refreshTopic: () => Promise<void>;
removeAllTopics: () => Promise<void>;
removeSessionTopics: () => Promise<void>;
removeTopic: (id: string) => Promise<void>;
Expand Down Expand Up @@ -125,7 +125,7 @@ export const chatTopic: StateCreator<
updateTopicTitleInSummary(topicId, topic.title);
},
onFinish: async (text) => {
topicService.updateTopic(topicId, { title: text });
await topicService.updateTopic(topicId, { title: text });
},
onLoadingChange: (loading) => {
updateTopicLoading(loading ? topicId : undefined);
Expand Down Expand Up @@ -238,12 +238,7 @@ export const chatTopic: StateCreator<
updateTopicLoading: (id) => {
set({ topicLoadingId: id }, false, n('updateTopicLoading'));
},
// TODO: I don't know why this ts error, so have to ignore it
// @ts-ignore
refreshTopic: async (params) => {
return mutate([SWR_USE_FETCH_TOPIC, get().activeId], params?.action, {
optimisticData: params?.optimisticData,
populateCache: false,
});
refreshTopic: async () => {
return mutate([SWR_USE_FETCH_TOPIC, get().activeId]);
},
});

0 comments on commit 5979de3

Please sign in to comment.