From edc0d1578b89c3b3e56e637de07137e069656fa8 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Tue, 20 May 2025 09:05:56 -0400 Subject: [PATCH] fix: always download 7.1 versioned files for patching --- api/dev/Unraid.net/myservers.cfg | 2 +- .../downloaded/.login.php.last-download-time | 2 +- .../downloaded/DefaultPageLayout.php | 48 ++++++++++++++----- .../DefaultPageLayout.php.last-download-time | 2 +- .../Notifications.page.last-download-time | 2 +- .../auth-request.php.last-download-time | 2 +- .../__test__/generic-modification.spec.ts | 9 ++-- ...efaultPageLayout.php.modified.snapshot.php | 48 ++++++++++++++----- .../patches/default-page-layout.patch | 6 +-- 9 files changed, 87 insertions(+), 34 deletions(-) diff --git a/api/dev/Unraid.net/myservers.cfg b/api/dev/Unraid.net/myservers.cfg index 6aef13471..1c664dad2 100644 --- a/api/dev/Unraid.net/myservers.cfg +++ b/api/dev/Unraid.net/myservers.cfg @@ -1,5 +1,5 @@ [api] -version="4.7.0" +version="4.4.1" extraOrigins="https://google.com,https://test.com" [local] sandbox="yes" diff --git a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/.login.php.last-download-time b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/.login.php.last-download-time index fe552f280..ee177936e 100644 --- a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/.login.php.last-download-time +++ b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/.login.php.last-download-time @@ -1 +1 @@ -1745509523866 +1747746267705 \ No newline at end of file diff --git a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/DefaultPageLayout.php b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/DefaultPageLayout.php index 65eb45cfd..2319e4766 100644 --- a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/DefaultPageLayout.php +++ b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/DefaultPageLayout.php @@ -769,7 +769,30 @@ unset($buttons,$button); // Build page content // Reload page every X minutes during extended viewing? -if (isset($myPage['Load']) && $myPage['Load'] > 0) echo "\n\n"; +if (isset($myPage['Load']) && $myPage['Load'] > 0) { + ?> + + "; $tab = 1; $pages = []; @@ -1265,39 +1288,41 @@ $('body').on('click','a,.ca_href', function(e) { } }); -// Start & stop live updates when window loses focus +// Only include window focus/blur event handlers when live updates are disabled +// to prevent unnecessary page reloads when live updates are already handling data refreshes +// nchanPaused / blurTimer used elsewhere so need to always be defined + var nchanPaused = false; var blurTimer = false; + $(window).focus(function() { nchanFocusStart(); }); // Stop nchan on loss of focus - $(window).blur(function() { blurTimer = setTimeout(function(){ nchanFocusStop(); },30000); }); - document.addEventListener("visibilitychange", (event) => { - - if (document.hidden) { - nchanFocusStop(); - } - if (document.hidden) { nchanFocusStop(); } else { 0):?> - window.location.reload(); + if ( dialogOpen() ) { + clearInterval(timers.reload); + setTimerReload(); + nchanFocusStart(); + } else { + window.location.reload(); + } nchanFocusStart(); } - }); function nchanFocusStart() { @@ -1338,6 +1363,7 @@ function nchanFocusStop(banner=true) { } } } + diff --git a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/DefaultPageLayout.php.last-download-time b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/DefaultPageLayout.php.last-download-time index baa751a3f..07b9923f6 100644 --- a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/DefaultPageLayout.php.last-download-time +++ b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/DefaultPageLayout.php.last-download-time @@ -1 +1 @@ -1745509523160 +1747746267422 \ No newline at end of file diff --git a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/Notifications.page.last-download-time b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/Notifications.page.last-download-time index bc6614739..778db5610 100644 --- a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/Notifications.page.last-download-time +++ b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/Notifications.page.last-download-time @@ -1 +1 @@ -1745509523526 +1747746267527 \ No newline at end of file diff --git a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/auth-request.php.last-download-time b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/auth-request.php.last-download-time index 805795285..221776b9e 100644 --- a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/auth-request.php.last-download-time +++ b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/__fixtures__/downloaded/auth-request.php.last-download-time @@ -1 +1 @@ -1745509524137 +1747746267741 \ No newline at end of file diff --git a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/generic-modification.spec.ts b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/generic-modification.spec.ts index a03704950..53bf8dd83 100644 --- a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/generic-modification.spec.ts +++ b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/generic-modification.spec.ts @@ -26,24 +26,25 @@ const patchTestCases: ModificationTestCase[] = [ { ModificationClass: DefaultPageLayoutModification, fileUrl: - 'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/include/DefaultPageLayout.php', + 'https://raw.githubusercontent.com/unraid/webgui/refs/heads/7.1/emhttp/plugins/dynamix/include/DefaultPageLayout.php', fileName: 'DefaultPageLayout.php', }, { ModificationClass: NotificationsPageModification, fileUrl: - 'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/Notifications.page', + 'https://raw.githubusercontent.com/unraid/webgui/refs/heads/7.1/emhttp/plugins/dynamix/Notifications.page', fileName: 'Notifications.page', }, { ModificationClass: SSOFileModification, fileUrl: - 'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/include/.login.php', + 'https://raw.githubusercontent.com/unraid/webgui/refs/heads/7.1/emhttp/plugins/dynamix/include/.login.php', fileName: '.login.php', }, { ModificationClass: AuthRequestModification, - fileUrl: 'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/auth-request.php', + fileUrl: + 'https://raw.githubusercontent.com/unraid/webgui/refs/heads/7.1/emhttp/auth-request.php', fileName: 'auth-request.php', }, ]; diff --git a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/snapshots/DefaultPageLayout.php.modified.snapshot.php b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/snapshots/DefaultPageLayout.php.modified.snapshot.php index a1c429590..4c509b7d6 100644 --- a/api/src/unraid-api/unraid-file-modifier/modifications/__test__/snapshots/DefaultPageLayout.php.modified.snapshot.php +++ b/api/src/unraid-api/unraid-file-modifier/modifications/__test__/snapshots/DefaultPageLayout.php.modified.snapshot.php @@ -778,7 +778,30 @@ unset($buttons,$button); // Build page content // Reload page every X minutes during extended viewing? -if (isset($myPage['Load']) && $myPage['Load'] > 0) echo "\n\n"; +if (isset($myPage['Load']) && $myPage['Load'] > 0) { + ?> + + "; $tab = 1; $pages = []; @@ -1266,39 +1289,41 @@ $('body').on('click','a,.ca_href', function(e) { } }); -// Start & stop live updates when window loses focus +// Only include window focus/blur event handlers when live updates are disabled +// to prevent unnecessary page reloads when live updates are already handling data refreshes +// nchanPaused / blurTimer used elsewhere so need to always be defined + var nchanPaused = false; var blurTimer = false; + $(window).focus(function() { nchanFocusStart(); }); // Stop nchan on loss of focus - $(window).blur(function() { blurTimer = setTimeout(function(){ nchanFocusStop(); },30000); }); - document.addEventListener("visibilitychange", (event) => { - - if (document.hidden) { - nchanFocusStop(); - } - if (document.hidden) { nchanFocusStop(); } else { 0):?> - window.location.reload(); + if ( dialogOpen() ) { + clearInterval(timers.reload); + setTimerReload(); + nchanFocusStart(); + } else { + window.location.reload(); + } nchanFocusStart(); } - }); function nchanFocusStart() { @@ -1339,6 +1364,7 @@ function nchanFocusStop(banner=true) { } } } + diff --git a/api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch b/api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch index c78d30244..cb87d5a89 100644 --- a/api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch +++ b/api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch @@ -80,7 +80,7 @@ Index: /usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php foreach ($buttons as $button) { annotate($button['file']); // include page specific stylesheets (if existing) -@@ -937,26 +946,18 @@ +@@ -960,26 +969,18 @@ case 'warning': bell2++; break; case 'normal' : bell3++; break; } @@ -112,11 +112,11 @@ Index: /usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php }); -@@ -1337,7 +1338,8 @@ - } +@@ -1363,7 +1364,8 @@ } } } + +