8000 feat: improve task management, completed task will not re-start again by magicdawn · Pull Request #181 · buxuku/SmartSub · GitHub
[go: up one dir, main page]

Skip to content
Prev Previous commit
chore: remove handleTask options
  • Loading branch information
magicdawn committed May 17, 2025
commit 945a80c6bd25a2f21456da4ea3a2eb96aa31f674
20 changes: 9 additions & 11 deletions renderer/components/TaskControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const TaskControls: FC<{
};
}, []);

const handleTask = async (options?: { silentNoNewTask?: boolean }) => {
const handleTask = async () => {
if (!files?.length) {
return toast(t('common:notification'), { description: t('home:noTask') });
}
Expand All @@ -62,12 +62,9 @@ const TaskControls: FC<{

const newTaskFiles = getNewTaskFiles(updatedFiles);
if (!newTaskFiles.length) {
if (!options?.silentNoNewTask) {
toast(t('common:notification'), {
description: t('home:allFilesProcessed'),
});
}
return;
return toast(t('common:notification'), {
description: t('home:allFilesProcessed'),
});
}

// if(formData.model && needsCoreML(formData.model)){
Expand Down Expand Up @@ -108,16 +105,17 @@ const TaskControls: FC<{
if (
taskStatus === 'running' &&
autoStartNewTaskWhenRunning &&
files.length
files.length &&
files.some((f) => !f.sent)
) {
handleTask({ silentNoNewTask: true });
handleTask();
}
}, [files.length]);

return (
<div className="flex gap-2 ml-auto">
{(taskStatus === 'idle' || taskStatus === 'completed') && (
<Button onClick={() => handleTask()} disabled={!files.length}>
<Button onClick={handleTask} disabled={!files.length}>
{t('home:startTask')}
</Button>
)}
Expand Down Expand Up @@ -147,7 +145,7 @@ const TaskControls: FC<{
</>
)}
{taskStatus === 'cancelled' && (
<Button onClick={() => handleTask()} disabled={!files.length}>
<Button onClick={handleTask} disabled={!files.length}>
{t('home:restartTask')}
</Button>
)}
Expand Down
0