mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-02-04 01:04:33 +00:00
Fix handling new spots by SSE when there weren't the max number already #3
This commit is contained in:
@@ -90,10 +90,6 @@ div.appearing-panel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
button#add-spot-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.spothole-card-text {
|
||||
line-height: 2.5em !important;
|
||||
}
|
||||
|
||||
@@ -42,12 +42,19 @@ function restartSSEConnection() {
|
||||
|
||||
// Add spot to internal data store
|
||||
spots.unshift(newSpot);
|
||||
spots = spots.slice(0, -1);
|
||||
// Add spot to table
|
||||
// Work out if we need to remove an old spot
|
||||
if (spots.length > $("#spots-to-fetch option:selected").val()) {
|
||||
spots = spots.slice(0, -1);
|
||||
// Drop oldest spot off the end of the table. This is two rows because of the mobile view extra rows
|
||||
$("#table tbody tr").last().remove();
|
||||
$("#table tbody tr").last().remove();
|
||||
}
|
||||
// If we had zero spots before (i.e. one now), the table will have a "No spots" row that we need to remove now
|
||||
// that we have one.
|
||||
$("#table tbody tr").last().remove();
|
||||
|
||||
// Add the new spot to table
|
||||
addSpotToTopOfTable(newSpot, true);
|
||||
// Drop oldest spot off the end of the table. This is two rows because of the mobile view extra rows
|
||||
$("#table tbody tr").last().remove();
|
||||
$("#table tbody tr").last().remove();
|
||||
};
|
||||
|
||||
evtSource.onerror = function(err) {
|
||||
@@ -387,11 +394,6 @@ function loadOptions() {
|
||||
$("#tableShowBearing").prop('checked', false);
|
||||
}
|
||||
|
||||
// Show the Add Spot button if spotting is allowed
|
||||
if (options["spot_allowed"]) {
|
||||
$("#add-spot-button").show();
|
||||
}
|
||||
|
||||
// Load spots (this will also set up the SSE connection to update them too)
|
||||
loadSpots();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user