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:
Smittix
2026-03-02 18:05:57 +00:00
parent 5534493bd1
commit e2e92b6b38
2 changed files with 160 additions and 84 deletions

View File

@@ -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);