Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

♻️ refactor(store): replace dynamic imports with static imports in actions (#13159)

Innei9eca3d2ec090
diff --git a/src/store/chat/slices/plugin/actions/optimisticUpdate.ts b/src/store/chat/slices/plugin/actions/optimisticUpdate.ts
index 9fb2354db1b..75e15f21cd6 100644
--- a/src/store/chat/slices/plugin/actions/optimisticUpdate.ts
+++ b/src/store/chat/slices/plugin/actions/optimisticUpdate.ts
@@ -13,7 +13,7 @@ import { type StoreSetter } from '@/store/types';
import { merge } from '@/utils/merge';
import { safeParseJSON } from '@/utils/safeParseJSON';
-import { displayMessageSelectors } from '../../message/selectors';
+import { dbMessageSelectors, displayMessageSelectors } from '../../message/selectors';
/**
* Params for batch updating tool message content, state, and error
@@ -207,7 +207,6 @@ export class PluginOptimisticUpdateActionImpl {
id: string,
context?: OptimisticUpdateContext,
): Promise<void> => {
- const { dbMessageSelectors } = await import('../../message/selectors');
const message = dbMessageSelectors.getDbMessageById(id)(this.#get());
if (!message || !message.tools) return;
diff --git a/src/store/file/slices/fileManager/action.ts b/src/store/file/slices/fileManager/action.ts
index dec69b85d86..af2c6822e3e 100644
--- a/src/store/file/slices/fileManager/action.ts
+++ b/src/store/file/slices/fileManager/action.ts
@@ -321,7 +321,6 @@ export class FileManageActionImpl {
);
// Perform the actual update
- const { documentService } = await import('@/services/document');
await documentService.updateDocument({ id: folderId, title: newName });
// Revalidate to get fresh data from server
diff --git a/src/store/userMemory/slices/base/action.ts b/src/store/userMemory/slices/base/action.ts
index f9e71a651a3..d70c3a419bf 100644
--- a/src/store/userMemory/slices/base/action.ts
+++ b/src/store/userMemory/slices/base/action.ts
@@ -4,7 +4,7 @@ import { type SWRResponse } from 'swr';
import useSWR from 'swr';
import { mutate, useClientDataSWR, useClientDataSWRWithSync } from '@/libs/swr';
-import { userMemoryService } from '@/services/userMemory';
+import { memoryCRUDService, userMemoryService } from '@/services/userMemory';
import { type StoreSetter } from '@/store/types';
import { type RetrieveMemoryParams, type RetrieveMemoryResult } from '@/types/userMemory';
import { LayersEnum } from '@/types/userMemory';
@@ -149,7 +149,6 @@ export class BaseActionImpl {
};
updateMemory = async (id: string, content: string, layer: LayersEnum): Promise<void> => {
- const { memoryCRUDService } = await import('@/services/userMemory');
const {
resetActivitiesList,
resetContextsList,