mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-26 19:47:20 +00:00
updates
This commit is contained in:
parent
b755f09abc
commit
64019cb0b4
@ -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);
|
||||
|
@ -1,2 +1,2 @@
|
||||
title: $:/config/Performance/Instrumentation
|
||||
text: no
|
||||
text: yes
|
||||
|
Loading…
Reference in New Issue
Block a user