+
}
onClick={(e) => {
e.stopPropagation();
diff --git a/src/features/Preview/index.tsx b/src/features/Preview/index.tsx
index 0426cbd..ff9419d 100644
--- a/src/features/Preview/index.tsx
+++ b/src/features/Preview/index.tsx
@@ -40,6 +40,7 @@ const Preview = memo(() => {
const currentTask = useStore(midjourneySelectors.currentActiveTask);
const showImage = taskLoading || currentTask?.imageUrl;
+
return (
{
const tasks = useStore((s) => s.tasks.map((t) => t.id), isEqual);
+ const hasMultiTasks = useStore(midjourneySelectors.hasMultiTasks);
return (
- tasks.length > 1 && (
+ hasMultiTasks && (
{tasks.map((task) => (
diff --git a/src/store/action.ts b/src/store/action.ts
index 2a51ce2..2e1c6e4 100644
--- a/src/store/action.ts
+++ b/src/store/action.ts
@@ -204,7 +204,9 @@ export const actions: StateCreator<
if (data) get().updateAppState(data, 'initApp');
// 如果第一次在 LobeChat 中触发插件,则创建 imagine 任务
- if (data.inLobeChat && data.tasks?.length === 0 && !!data.prompts) {
+ const noTask = data.tasks?.length === 0 || !data.tasks;
+
+ if (data.inLobeChat && noTask && !!data.prompts) {
get().createImagineTask();
}
},
diff --git a/src/store/selectors.ts b/src/store/selectors.ts
index 616ed9c..f42c676 100644
--- a/src/store/selectors.ts
+++ b/src/store/selectors.ts
@@ -31,12 +31,14 @@ const isCurrentTaskRunning = (s: MidjourneyStore) => {
const isTaskActive = (id: string) => (s: MidjourneyStore) => {
return getTaskById(id)(s)?.id === s.activeTaskId;
};
+const hasMultiTasks = (s: MidjourneyStore) => s.tasks.length > 1;
const isInLobeChat = (s: MidjourneyStore) => s.inLobeChat;
export const midjourneySelectors = {
currentActiveTask,
currentTaskProgress,
getTaskById,
+ hasMultiTasks,
isAnyTaskRunning,
isCurrentTaskRunning,
isInLobeChat,