Skip to content

Commit a03291a

Browse files
committed
Only update LastPolled on successful poll, reset cellular chart state on mount/unmount
Failed polls no longer stamp LastPolled, so the timer retries on the next tick instead of waiting the full polling interval. Previously SSH failures during modem reboots created extended data gaps. Cellular chart module now resets all state (time range, filters, custom range) in both mount and unmount, matching the SFP chart pattern. Fixes stale 1h view persisting when navigating back from the dashboard.
1 parent e027252 commit a03291a

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/NetworkOptimizer.Web/Services/CellularModemService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ private ModemPollContext ToPollContext(ModemConfiguration modem)
218218

219219
if (stats != null)
220220
{
221-
// Update LastPolled in database
222-
await UpdateModemConfigAsync(modem.Id, null);
221+
await UpdateModemConfigAsync(modem.Id, null, success: true);
223222

224223
lock (_lock)
225224
{
@@ -234,14 +233,14 @@ private ModemPollContext ToPollContext(ModemConfiguration modem)
234233
}
235234
else
236235
{
237-
await UpdateModemConfigAsync(modem.Id, "Poll returned no data");
236+
await UpdateModemConfigAsync(modem.Id, "Poll returned no data", success: false);
238237
return (false, "Failed to poll modem - no data returned");
239238
}
240239
}
241240
catch (Exception ex)
242241
{
243242
_logger.LogError(ex, "Error refreshing modem {Name}", modem.Name);
244-
await UpdateModemConfigAsync(modem.Id, ex.Message);
243+
await UpdateModemConfigAsync(modem.Id, ex.Message, success: false);
245244
return (false, $"Error: {ex.Message}");
246245
}
247246
}
@@ -336,7 +335,7 @@ private async Task PollAllModemsAsync()
336335
}
337336
}
338337

339-
private async Task UpdateModemConfigAsync(int modemId, string? error)
338+
private async Task UpdateModemConfigAsync(int modemId, string? error, bool success)
340339
{
341340
try
342341
{
@@ -346,7 +345,8 @@ private async Task UpdateModemConfigAsync(int modemId, string? error)
346345
var config = await repository.GetModemConfigurationAsync(modemId);
347346
if (config != null)
348347
{
349-
config.LastPolled = DateTime.UtcNow;
348+
if (success)
349+
config.LastPolled = DateTime.UtcNow;
350350
config.LastError = error;
351351
config.UpdatedAt = DateTime.UtcNow;
352352
await repository.SaveModemConfigurationAsync(config);

src/NetworkOptimizer.Web/wwwroot/js/cellular-charts.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,15 @@ function shiftWindow(container, direction) {
282282
}
283283

284284
export async function mount(elId) {
285+
// Reset all state in case unmount didn't complete (Blazor Dispose race)
286+
stopPoll();
287+
currentRangeHours = 24;
288+
windowOffset = 0;
289+
isCustomRange = false;
290+
customFrom = null;
291+
customTo = null;
292+
modemMeta = [];
293+
visibility = {};
285294
containerId = elId;
286295
const container = document.getElementById(elId);
287296
if (!container) return;
@@ -393,10 +402,18 @@ export function soloModem(modemId) {
393402
export function unmount() {
394403
stopPoll();
395404
if (visibilityObserver) { visibilityObserver.disconnect(); visibilityObserver = null; }
405+
if (fetchController) { fetchController.abort(); fetchController = null; }
396406
if (rsrpChart) { rsrpChart.destroy(); rsrpChart = null; }
397407
if (rsrqChart) { rsrqChart.destroy(); rsrqChart = null; }
398408
if (snrChart) { snrChart.destroy(); snrChart = null; }
399409
if (qualityChart) { qualityChart.destroy(); qualityChart = null; }
410+
containerId = null;
400411
modemMeta = [];
401412
visibility = {};
413+
currentRangeHours = 24;
414+
windowOffset = 0;
415+
isCustomRange = false;
416+
customFrom = null;
417+
customTo = null;
418+
isInViewport = true;
402419
}

0 commit comments

Comments
 (0)