Skip to content

Commit

Permalink
🚸 fix: improve plugin ux
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jan 18, 2024
1 parent 8387a1e commit 7a7b97b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 LobeHub
Copyright (c) 2023 - current LobeHub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "plugin-identifier",
"name": "midjourney-webui",
"version": "1.2.2",
"private": true,
"description": "This is the plugin template for LobeChat plugin development",
Expand Down
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"identifier": "midjourney",
"meta": {
"avatar": "https://cdn.discordapp.com/icons/662267976984297473/39128f6c9fc33f4c95a27d4c601ad7db.webp",
"tags": ["midjourney", "draw"],
"title": "Midjourney",
"description": "midjourney plugin"
"description": "Unleash creativity with Midjourney, effortlessly generating unique AI-driven images through simple prompts. Add visual flair to your conversations with Midjourney's artistic touch.",
"tags": ["AI Image Generation", "Midjourney", "Visualization"]
},
"settings": {
"type": "object",
Expand Down
4 changes: 2 additions & 2 deletions src/features/Preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Preview = memo(() => {
const [progress, taskLoading, inLobeChat] = useStore((s) => [
midjourneySelectors.currentTaskProgress(s),
midjourneySelectors.isCurrentTaskRunning(s),
s.inLobeChat,
midjourneySelectors.isInLobeChat(s),
]);

const { styles, theme } = useStyles();
Expand All @@ -51,7 +51,7 @@ const Preview = memo(() => {
>
{showImage ? (
<ImagePreview />
) : (
) : inLobeChat ? null : (
<Center height={'100%'} width={'100%'}>
<Guide />
</Center>
Expand Down
12 changes: 7 additions & 5 deletions src/features/TaskList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const TaskList = memo(() => {
const tasks = useStore((s) => s.tasks.map((t) => t.id), isEqual);

return (
<Flexbox gap={6} height={64} horizontal>
{tasks.map((task) => (
<TaskItem id={task} key={task} />
))}
</Flexbox>
tasks.length > 1 && (
<Flexbox gap={6} height={64} horizontal>
{tasks.map((task) => (
<TaskItem id={task} key={task} />
))}
</Flexbox>
)
);
});

Expand Down
5 changes: 5 additions & 0 deletions src/store/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ export const actions: StateCreator<
{
onSuccess: (data: AppState) => {
if (data) get().updateAppState(data, 'initApp');

// 如果第一次在 LobeChat 中触发插件,则创建 imagine 任务
if (data.inLobeChat && data.tasks?.length === 0 && !!data.prompts) {
get().createImagineTask();
}
},
revalidateOnFocus: false,
},
Expand Down
2 changes: 2 additions & 0 deletions src/store/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ const isCurrentTaskRunning = (s: MidjourneyStore) => {
const isTaskActive = (id: string) => (s: MidjourneyStore) => {
return getTaskById(id)(s)?.id === s.activeTaskId;
};
const isInLobeChat = (s: MidjourneyStore) => s.inLobeChat;

export const midjourneySelectors = {
currentActiveTask,
currentTaskProgress,
getTaskById,
isAnyTaskRunning,
isCurrentTaskRunning,
isInLobeChat,
isTaskActive,
isTasksEmpty,
};

0 comments on commit 7a7b97b

Please sign in to comment.