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),
|
styleDeferredChanges = Object.create(null),
|
||||||
mainTimerId,
|
mainTimerId,
|
||||||
styleTimerId,
|
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
|
// Check if only tiddlers that are throttled have changed
|
||||||
var onlyThrottledTiddlersHaveChanged = true;
|
var onlyThrottledTiddlersHaveChanged = true;
|
||||||
for(var title in changes) {
|
for(var title in changes) {
|
||||||
var tiddler = $tw.wiki.getTiddler(title);
|
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;
|
onlyThrottledTiddlersHaveChanged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Defer the change if only drafts have changed
|
// Defer the change if only drafts have changed
|
||||||
if(timerId) {
|
if(options.timerId) {
|
||||||
clearTimeout(timerId);
|
clearTimeout(options.timerId);
|
||||||
}
|
}
|
||||||
timerId = null;
|
options.timerId = null;
|
||||||
if(onlyThrottledTiddlersHaveChanged) {
|
if(onlyThrottledTiddlersHaveChanged) {
|
||||||
var timeout = parseInt($tw.wiki.getTiddlerText(DRAFT_TIDDLER_TIMEOUT_TITLE,""),10);
|
var timeout = parseInt($tw.wiki.getTiddlerText(DRAFT_TIDDLER_TIMEOUT_TITLE,""),10);
|
||||||
if(isNaN(timeout)) {
|
if(isNaN(timeout)) {
|
||||||
timeout = THROTTLE_REFRESH_TIMEOUT;
|
timeout = THROTTLE_REFRESH_TIMEOUT;
|
||||||
}
|
}
|
||||||
timerId = setTimeout(throttledRefresh,timeout);
|
options.timerId = setTimeout(options.throttledRefresh,timeout);
|
||||||
$tw.utils.extend(deferredChanges,changes);
|
$tw.utils.extend(options.deferredChanges,changes);
|
||||||
} else {
|
} else {
|
||||||
$tw.utils.extend(deferredChanges,changes);
|
$tw.utils.extend(options.deferredChanges,changes);
|
||||||
callback();
|
options.callback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var styleRefresh = function() {
|
var styleRefresh = function() {
|
||||||
@ -128,10 +130,24 @@ exports.startup = function() {
|
|||||||
var mainThrottledRefresh = $tw.perf.report("throttledMainRefresh",mainRefresh),
|
var mainThrottledRefresh = $tw.perf.report("throttledMainRefresh",mainRefresh),
|
||||||
styleThrottledRefresh = $tw.perf.report("throttledStyleRefresh",styleRefresh);
|
styleThrottledRefresh = $tw.perf.report("throttledStyleRefresh",styleRefresh);
|
||||||
styleRefreshHandler = function(changes) {
|
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) {
|
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",styleRefreshHandler);
|
||||||
$tw.wiki.addEventListener("change",mainRefreshHandler);
|
$tw.wiki.addEventListener("change",mainRefreshHandler);
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
title: $:/config/Performance/Instrumentation
|
title: $:/config/Performance/Instrumentation
|
||||||
text: no
|
text: yes
|
||||||
|
Loading…
Reference in New Issue
Block a user