Skip to content

Commit

Permalink
Make sure actions are run instantly if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Jermolene committed Jan 2, 2025
1 parent 6a650ae commit 3852f4c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/modules/wiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ exports.runFilteredActions = function() {
}
var self = this;
var now = (new Date()).getTime();
this.timestampLastRunFilteredActions = this.timestampLastRunFilteredActions || now;
this.intervalFilteredActions = this.intervalFilteredActions || 500;
// Minimum interval between runs
this.intervalFilteredActions = this.intervalFilteredActions || 100;
// Time of the last run
this.timestampLastRunFilteredActions = this.timestampLastRunFilteredActions || now - this.intervalFilteredActions * 2;
// If we've run the filtered actions recently, queue another run
if((this.timestampLastRunFilteredActions + this.intervalFilteredActions) > now) {
if(!this.filterActionTimerId) {
this.filterActionTimerId = setTimeout(function() {
Expand All @@ -188,7 +191,9 @@ exports.runFilteredActions = function() {
}
return;
}
// Record the time of this run
this.timestampLastRunFilteredActions = now;
// Get the list of filtered action tiddlers and process each one
var filteredActions = $tw.wiki.getTiddlersWithTag("$:/tags/FilteredActions");
$tw.utils.each(filteredActions,function(filteredActionTitle) {
var tiddler = self.getTiddler(filteredActionTitle);
Expand Down

0 comments on commit 3852f4c

Please sign in to comment.