From 3437cea13ca3999d3f91fdc0e9a6ba57b6fd9b4f Mon Sep 17 00:00:00 2001 From: Ivan Neplokhov Date: Thu, 5 Feb 2026 11:54:16 +0400 Subject: [PATCH] some --- package.json | 2 +- src/renderer/hooks/useTaskActions.js | 83 +++++++++++++++------------- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 6fd4907..195f254 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "telegram-invite-automation", - "version": "1.5.0", + "version": "1.6.0", "private": true, "description": "Automated user parsing and invites for Telegram groups", "main": "src/main/index.js", diff --git a/src/renderer/hooks/useTaskActions.js b/src/renderer/hooks/useTaskActions.js index b7dcfed..901ea57 100644 --- a/src/renderer/hooks/useTaskActions.js +++ b/src/renderer/hooks/useTaskActions.js @@ -108,49 +108,52 @@ export default function useTaskActions({ setTaskNotice({ text: `Автоназначены аккаунты: ${accountIds.length}`, tone: "success", source }); } } - if (!accountIds.length) { - if (!silent) { - showNotification("Нет аккаунтов для этой задачи.", "error"); - } - return; - } + const hasNoAccounts = !accountIds.length; const roleEntries = Object.values(accountRolesMap); - if (roleEntries.length) { - const hasMonitor = roleEntries.some((item) => item.monitor); - const hasInvite = roleEntries.some((item) => item.invite); - const hasConfirm = roleEntries.some((item) => item.confirm); - if (!hasMonitor) { - if (!silent) { - showNotification("Нужен хотя бы один аккаунт с ролью мониторинга.", "error"); + if (accountIds.length > 0) { + if (roleEntries.length) { + const hasMonitor = roleEntries.some((item) => item.monitor); + const hasInvite = roleEntries.some((item) => item.invite); + const hasConfirm = roleEntries.some((item) => item.confirm); + if (!hasMonitor) { + if (!silent) { + showNotification("Нужен хотя бы один аккаунт с ролью мониторинга.", "error"); + } + return; } - return; - } - if (!hasInvite) { - if (!silent) { - showNotification("Нужен хотя бы один аккаунт с ролью инвайта.", "error"); + if (!hasInvite) { + if (!silent) { + showNotification("Нужен хотя бы один аккаунт с ролью инвайта.", "error"); + } + return; } - return; - } - if (nextForm.separateConfirmRoles && !hasConfirm) { - if (!silent) { - showNotification("Нужен хотя бы один аккаунт с ролью подтверждения.", "error"); + if (nextForm.separateConfirmRoles && !hasConfirm) { + if (!silent) { + showNotification("Нужен хотя бы один аккаунт с ролью подтверждения.", "error"); + } + return; } - return; - } - } else { - const requiredAccounts = nextForm.requireSameBotInBoth - ? Math.max(1, Number(nextForm.maxCompetitorBots || 1)) - : nextForm.separateBotRoles + } else { + const requiredAccounts = nextForm.requireSameBotInBoth ? Math.max(1, Number(nextForm.maxCompetitorBots || 1)) - + Math.max(1, Number(nextForm.maxOurBots || 1)) - + (nextForm.separateConfirmRoles ? Math.max(1, Number(nextForm.maxConfirmBots || 1)) : 0) - : 1; - if (accountIds.length < requiredAccounts) { - if (!silent) { - showNotification(`Нужно минимум ${requiredAccounts} аккаунтов для выбранного режима.`, "error"); + : nextForm.separateBotRoles + ? Math.max(1, Number(nextForm.maxCompetitorBots || 1)) + + Math.max(1, Number(nextForm.maxOurBots || 1)) + + (nextForm.separateConfirmRoles ? Math.max(1, Number(nextForm.maxConfirmBots || 1)) : 0) + : 1; + if (accountIds.length < requiredAccounts) { + if (!silent) { + showNotification(`Нужно минимум ${requiredAccounts} аккаунтов для выбранного режима.`, "error"); + } + return; } - return; } + } else if (!silent) { + setTaskNotice({ + text: "Задача сохранена как черновик. Добавьте аккаунты во вкладке «Аккаунты».", + tone: "warn", + source + }); } const accountRoles = Object.entries(accountRolesMap).map(([id, roles]) => ({ accountId: Number(id), @@ -167,7 +170,13 @@ export default function useTaskActions({ }); if (result.ok) { if (!silent) { - setTaskNotice({ text: "Задача сохранена.", tone: "success", source }); + setTaskNotice({ + text: hasNoAccounts + ? "Задача сохранена как черновик. Добавьте аккаунты во вкладке «Аккаунты»." + : "Задача сохранена.", + tone: hasNoAccounts ? "warn" : "success", + source + }); } else { setAutosaveNote("Автосохранено"); if (autosaveNoteTimer.current) {