mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 14:50:00 -07:00
fix: cache ISS position/schedule and parallelize SSTV init API calls
SSTV mode was slow to populate next-pass countdown and ISS location map due to uncached skyfield computation and sequential JS API calls. - Cache ISS position (10s TTL) and schedule (15min TTL, keyed by rounded lat/lon) - Cache skyfield timescale object (expensive to create on every request) - Reduce external API timeouts from 5s to 3s - Fire checkStatus, loadImages, loadIssSchedule, updateIssPosition in parallel via Promise.all Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,13 +39,23 @@ const SSTV = (function() {
|
||||
* Initialize the SSTV mode
|
||||
*/
|
||||
function init() {
|
||||
checkStatus();
|
||||
loadImages();
|
||||
// Load location inputs first (sync localStorage read needed for lat/lon params)
|
||||
loadLocationInputs();
|
||||
loadIssSchedule();
|
||||
|
||||
// Fire all API calls in parallel — schedule is the slowest, don't let it block
|
||||
Promise.all([
|
||||
checkStatus(),
|
||||
loadImages(),
|
||||
loadIssSchedule(),
|
||||
updateIssPosition(),
|
||||
]).catch(err => console.error('SSTV init error:', err));
|
||||
|
||||
// DOM-only setup (no network, fast)
|
||||
initMap();
|
||||
startIssTracking();
|
||||
startCountdown();
|
||||
// ISS tracking interval (first call already in Promise.all above)
|
||||
if (issUpdateInterval) clearInterval(issUpdateInterval);
|
||||
issUpdateInterval = setInterval(updateIssPosition, 5000);
|
||||
// Ensure Leaflet recomputes dimensions after the SSTV pane becomes visible.
|
||||
setTimeout(() => invalidateMap(), 80);
|
||||
setTimeout(() => invalidateMap(), 260);
|
||||
|
||||
Reference in New Issue
Block a user