Only include credentials (if we have them) on map page and on the SSE aspect of the spots page, to prevent first-time load delays on spots

This commit is contained in:
Ian Renton
2026-05-15 14:59:19 +01:00
parent 363735a235
commit 2026b46113
13 changed files with 43 additions and 35 deletions

View File

@@ -12,7 +12,7 @@ function loadSpots() {
}
// Make the new query
$.getJSON('/api/v1/spots' + buildQueryString(), function(jsonData) {
$.getJSON('/api/v1/spots' + buildQueryString(false), function(jsonData) {
// Store data
spots = jsonData;
// Update table
@@ -31,7 +31,7 @@ function startSSEConnection() {
if (evtSource != null) {
evtSource.close();
}
evtSource = new EventSource('/api/v1/spots/stream' + buildQueryString());
evtSource = new EventSource('/api/v1/spots/stream' + buildQueryString(true));
evtSource.onmessage = function(event) {
// Get the new spot
@@ -78,7 +78,7 @@ function startSSEConnection() {
}
// Build a query string for the API, based on the filters that the user has selected.
function buildQueryString() {
function buildQueryString(includeCredentials) {
var str = "?";
["dx_continent", "de_continent", "mode", "source", "band", "sig"].forEach(fn => {
if (!allFilterOptionsSelected(fn)) {
@@ -89,7 +89,9 @@ function buildQueryString() {
if ($("#search").val() != "") {
str = str + "&text_includes=" + encodeURIComponent($("#search").val());
}
str = str + getCredentialQueryString();
if (includeCredentials) {
str = str + getCredentialQueryString();
}
return str;
}