import { parentPort } from 'node:worker_threads' // Отдельный поток: только тикающий таймер, никакой работы с IMAP здесь не делаем — // imapflow-соединения и расшифрованные credentials живут в main-потоке (AccountManager), // worker_threads не имеют доступа к Electron API (safeStorage и т.п.), поэтому реальная // очистка выполняется в RetentionService по сигналу тика. type WorkerMessage = | { type: 'setInterval'; intervalMinutes: number } let timer: ReturnType | null = null function applyInterval(intervalMinutes: number): void { if (timer) { clearInterval(timer) timer = null } if (intervalMinutes > 0) { timer = setInterval(() => { parentPort?.postMessage({ type: 'tick' }) }, intervalMinutes * 60_000) } } parentPort?.on('message', (msg: WorkerMessage) => { if (msg.type === 'setInterval') { applyInterval(msg.intervalMinutes) } })