This commit is contained in:
Gauthier Dandele
2024-12-08 11:48:30 +01:00
committed by GitHub
2 changed files with 40 additions and 1 deletions

View File

@@ -647,7 +647,12 @@ RED.palette.editor = (function() {
updateAllowList = RED.utils.parseModuleList(updateAllowList);
updateDenyList = RED.utils.parseModuleList(updateDenyList);
catalogues = RED.settings.theme('palette.catalogues') || ['https://catalogue.nodered.org/catalogue.json']
catalogues = RED.settings.theme('palette.catalogues') || ['https://catalogue.nodered.org/catalogue.json'];
if (RED.settings.get("editorTheme.palette.checkForUpdates", false) === true) {
// Enable checking for updates triggered every 30 minutes
initCheckForUpdatesInterval();
}
createSettingsPane();
@@ -777,6 +782,35 @@ RED.palette.editor = (function() {
});
}
/**
* Initializes the check for updates triggered every 30 minutes.
* This interval is based on the cumulative active window time.
*/
function initCheckForUpdatesInterval() {
let activeTime = 0, lastActiveTime = Date.now();
const INTERVAL = 30 * 60; // 30min
document.addEventListener("visibilitychange", function () {
if (document.visibilityState === "visible") {
lastActiveTime = Date.now();
} else {
activeTime += (Date.now() - lastActiveTime) / 1000;
}
});
setInterval(function () {
if (document.visibilityState === "visible") {
activeTime += (Date.now() - lastActiveTime) / 1000;
lastActiveTime = Date.now();
if (activeTime >= INTERVAL) {
activeTime = 0;
refreshCatalogues();
}
}
}, 1000 * 60); // refresh every minute
}
function getSettingsPane() {
initInstallTab();
editorTabs.activateTab('nodes');

View File

@@ -416,6 +416,11 @@ module.exports = {
* If not set, the following default order is used:
*/
//categories: ['subflows', 'common', 'function', 'network', 'sequence', 'parser', 'storage'],
/**
* To enable checking for updates every 30min when the editor is open and active.
*/
checkForUpdates: false,
},
projects: {