File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -299,7 +299,7 @@ function updateChevrons(currentMac) {
299299
300300 showSpinner();
301301
302- cacheDevices().then(() => {
302+ cacheDevices(true ).then(() => {
303303 hideSpinner();
304304
305305 // Retry after re-caching
@@ -507,7 +507,7 @@ function updateDevicePageName(mac) {
507507 if (mac != 'new' && (name === null|| owner === null)) {
508508 console.warn("Device not found in cache, retrying after re-cache:", mac);
509509 showSpinner();
510- cacheDevices().then(() => {
510+ cacheDevices(true ).then(() => {
511511 hideSpinner();
512512 // Retry after successful cache
513513 updateDevicePageName(mac);
Original file line number Diff line number Diff line change @@ -451,11 +451,23 @@ function getDevDataByMac(macAddress, dbColumn) {
451451}
452452
453453// -----------------------------------------------------------------------------
454- // Cache the devices as one JSON
455- function cacheDevices ( )
454+ /**
455+ * Fetches the full device list from table_devices.json and stores it in
456+ * localStorage under CACHE_KEYS.DEVICES_ALL.
457+ *
458+ * On subsequent calls the fetch is skipped if the initFlag is already set,
459+ * unless forceRefresh is true. Pass forceRefresh = true whenever the caller
460+ * knows the cached list may be stale (e.g. a device was not found by MAC and
461+ * the page needs to recover without a full clearCache()).
462+ *
463+ * @param {boolean } [forceRefresh=false] - When true, bypasses the initFlag
464+ * guard and always fetches fresh data from the server.
465+ * @returns {Promise<void> } Resolves when the cache has been populated.
466+ */
467+ function cacheDevices ( forceRefresh = false )
456468{
457469 return new Promise ( ( resolve , reject ) => {
458- if ( getCache ( CACHE_KEYS . initFlag ( 'cacheDevices' ) ) === "true" )
470+ if ( ! forceRefresh && getCache ( CACHE_KEYS . initFlag ( 'cacheDevices' ) ) === "true" )
459471 {
460472 // One-time migration: normalize legacy { data: [...] } wrapper to a plain array.
461473 // Old cache entries from prior versions stored the raw API envelope; re-write
You can’t perform that action at this time.
0 commit comments