Align mail columns and add live sync dialogs with targeted cancellation

This commit is contained in:
alberto committed 2026-10-17 09:57:34 +02:00
1 parent e536f0939c
commit 573e0aa24e
15 files changed
+133 -20

No files matched your search

+3 -3
View File
@@ -1,11 +1,11 @@
import {readFile,writeFile,rename} from 'node:fs/promises';
import {randomUUID} from 'node:crypto';
export async function reservePacketSlot(client,controller,frequencyMHz,port){
if(!controller)return;
export async function reservePacketSlot(client,controller,frequencyMHz,port,{signal}={}){
signal?.throwIfAborted();if(!controller)return;
const began=Date.now(),request={id:randomUUID(),frequencyMHz,expiresAt:began+90000};client.job.controller={...controller,id:request.id};await client.persist();
await writeFile(controller.requestFile+'.tmp',JSON.stringify(request));await rename(controller.requestFile+'.tmp',controller.requestFile);
const deadline=Date.now()+65000;
while(Date.now()<deadline){try{const state=JSON.parse(await readFile(controller.statusFile,'utf8'));if(state.manualRequestId===request.id&&state.phase==='vhf'&&state.pttReady===true&&Math.abs(Number(state.frequency)-frequencyMHz)<0.0001&&Date.now()-Date.parse(state.at)<5000){const html=await client.fwd.bpq('/Node/Port?'+port);if(/Connected to TNC/.test(html)&&/1200bd/.test(html)){client.job.controller.preparationMs=Date.now()-began;await client.persist();return;}}}catch{}await new Promise(resolve=>setTimeout(resolve,300));}
while(Date.now()<deadline){signal?.throwIfAborted();try{const state=JSON.parse(await readFile(controller.statusFile,'utf8'));if(state.manualRequestId===request.id&&state.phase==='vhf'&&state.pttReady===true&&Math.abs(Number(state.frequency)-frequencyMHz)<0.0001&&Date.now()-Date.parse(state.at)<5000){const html=await client.fwd.bpq('/Node/Port?'+port);if(/Connected to TNC/.test(html)&&/1200bd/.test(html)){client.job.controller.preparationMs=Date.now()-began;await client.persist();return;}}}catch{}await new Promise(resolve=>setTimeout(resolve,300));}
throw Error('Modem packet non pronto: nessuna chiamata avviata');
}
export async function releasePacketSlot(client){