From 64019cb0b4539e4abe4b3de5c4d2733b19a60602 Mon Sep 17 00:00:00 2001 From: BurningTreeC Date: Tue, 15 Oct 2024 18:23:18 +0200 Subject: [PATCH] updates --- core/modules/startup/windows.js | 38 +++++++++++++------ .../config/PerformanceInstrumentation.tid | 2 +- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js index 9f0e9d6d5..52b389fd9 100644 --- a/core/modules/startup/windows.js +++ b/core/modules/startup/windows.js @@ -85,30 +85,32 @@ exports.startup = function() { styleDeferredChanges = Object.create(null), mainTimerId, styleTimerId, - throttledRefreshFn = function(changes,deferredChanges,timerId,throttledRefresh,callback,mainCondition,styleCondition) { + throttledRefreshFn = function(changes,options) { + options = options || {}; // Check if only tiddlers that are throttled have changed var onlyThrottledTiddlersHaveChanged = true; for(var title in changes) { var tiddler = $tw.wiki.getTiddler(title); - if(!$tw.wiki.isVolatileTiddler(title) && (!tiddler || !(tiddler.hasField("draft.of") || tiddler.hasField("throttle.refresh") || (mainCondition && tiddler.hasField("throttle.refresh.main")) || (styleCondition && tiddler.hasField("throttle.refresh.style"))))) { + if(!$tw.wiki.isVolatileTiddler(title) && (!tiddler || !(tiddler.hasField("draft.of") || tiddler.hasField("throttle.refresh") || + (options.mainCondition && tiddler.hasField("throttle.refresh.main")) || (options.styleCondition && tiddler.hasField("throttle.refresh.style"))))) { onlyThrottledTiddlersHaveChanged = false; } } // Defer the change if only drafts have changed - if(timerId) { - clearTimeout(timerId); + if(options.timerId) { + clearTimeout(options.timerId); } - timerId = null; + options.timerId = null; if(onlyThrottledTiddlersHaveChanged) { var timeout = parseInt($tw.wiki.getTiddlerText(DRAFT_TIDDLER_TIMEOUT_TITLE,""),10); if(isNaN(timeout)) { timeout = THROTTLE_REFRESH_TIMEOUT; } - timerId = setTimeout(throttledRefresh,timeout); - $tw.utils.extend(deferredChanges,changes); + options.timerId = setTimeout(options.throttledRefresh,timeout); + $tw.utils.extend(options.deferredChanges,changes); } else { - $tw.utils.extend(deferredChanges,changes); - callback(); + $tw.utils.extend(options.deferredChanges,changes); + options.callback(); } }; var styleRefresh = function() { @@ -128,10 +130,24 @@ exports.startup = function() { var mainThrottledRefresh = $tw.perf.report("throttledMainRefresh",mainRefresh), styleThrottledRefresh = $tw.perf.report("throttledStyleRefresh",styleRefresh); styleRefreshHandler = function(changes) { - throttledRefreshFn(changes,styleDeferredChanges,styleTimerId,styleThrottledRefresh,styleRefresh,false,true); + throttledRefreshFn(changes,{ + deferredChanged: styleDeferredChanges, + timerId: styleTimerId, + throttledRefresh: styleThrottledRefresh, + callback: styleRefresh, + mainCondition: false, + styleCondition: true + }); }; mainRefreshHandler = function(changes) { - throttledRefreshFn(changes,mainDeferredChanges,mainTimerId,mainThrottledRefresh,mainRefresh,true,false); + throttledRefreshFn(changes,{ + deferredChanges: mainDeferredChanges, + timerId: mainTimerId, + throttledRefresh: mainThrottledRefresh, + callback: mainRefresh, + mainCondition: true, + styleCondition: false + }); }; $tw.wiki.addEventListener("change",styleRefreshHandler); $tw.wiki.addEventListener("change",mainRefreshHandler); diff --git a/core/wiki/config/PerformanceInstrumentation.tid b/core/wiki/config/PerformanceInstrumentation.tid index ccae6842e..e4220f287 100644 --- a/core/wiki/config/PerformanceInstrumentation.tid +++ b/core/wiki/config/PerformanceInstrumentation.tid @@ -1,2 +1,2 @@ title: $:/config/Performance/Instrumentation -text: no +text: yes