mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
Intermediate reload of map data if QRZ/HamQTH credentials are supplied
This commit is contained in:
+22
-2
@@ -38,8 +38,13 @@ function loadSpots() {
|
||||
if (evtSource != null) {
|
||||
evtSource.close();
|
||||
}
|
||||
// On first fetch, don't include QRZ/HamQTH credentials. This will cause some inaccurate
|
||||
// marker positions but avoids having to wait a minute or more for all the lookups to fire.
|
||||
// Including QRZ/HamQTH lookups to improve positions causes the load to be really slow, so on first load
|
||||
// the user would be waiting ages without data and will think it's broken. We therefore load in several
|
||||
// stages:
|
||||
// 1) Load without any credentials
|
||||
// 2) (If we have credentials) reload with them, replacing what's already there,
|
||||
// 3) Subscribe to the SSE endpoint (with credentials if we have them) so that updates come with augmented
|
||||
// data if they can.
|
||||
$.getJSON('/api/v1/spots' + buildQueryString(false), function (jsonData) {
|
||||
// Store data
|
||||
spots = jsonData;
|
||||
@@ -48,6 +53,21 @@ function loadSpots() {
|
||||
if ($("#showTerminator")[0].checked) {
|
||||
terminator.setTime();
|
||||
}
|
||||
// Check if we have any credentials to use
|
||||
if (getCredentialQueryString() !== "") {
|
||||
// OK, we have credentials and have loaded once without them so the user has a basic map. Now reload
|
||||
// with the credentials and replace what's on the map, so we can improve the data.
|
||||
$.getJSON('/api/v1/spots' + buildQueryString(true), function (jsonData2) {
|
||||
spots = jsonData2;
|
||||
updateMap();
|
||||
// Now start the ongoing SSE connection
|
||||
startSSEConnection();
|
||||
});
|
||||
} else {
|
||||
// We had no credentials with which to augment the data anyway, so just start the SSE connection
|
||||
// now
|
||||
startSSEConnection();
|
||||
}
|
||||
// Start the ongoing SSE connection
|
||||
startSSEConnection();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user