From 806960afc7327c2f64005b014f037ff6e2011417 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Mon, 6 Jan 2025 16:43:02 +0000 Subject: [PATCH] Remove duplicates from filter tracker results --- core/modules/filter-tracker.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/modules/filter-tracker.js b/core/modules/filter-tracker.js index 695126835..3b2d8ae0f 100644 --- a/core/modules/filter-tracker.js +++ b/core/modules/filter-tracker.js @@ -64,14 +64,19 @@ FilterTracker.prototype.processTrackers = function() { }; FilterTracker.prototype.processTracker = function(index) { - var tracker = this.trackers[index], - results = this.wiki.filterTiddlers(tracker.filterString); - // Process the results + var tracker = this.trackers[index]; + var results = []; + // Evaluate the filter and remove duplicate results + $tw.utils.each(this.wiki.filterTiddlers(tracker.filterString),function(title) { + $tw.utils.pushTop(results,title); + }); + // Process the newly entered results $tw.utils.each(results,function(title) { if(tracker.previousResults.indexOf(title) === -1 && !tracker.resultValues[title] && tracker.fnEnter) { tracker.resultValues[title] = tracker.fnEnter(title) || true; } }); + // Process the results that have just left $tw.utils.each(tracker.previousResults,function(title) { if(results.indexOf(title) === -1 && tracker.resultValues[title] && tracker.fnLeave) { tracker.fnLeave(title,tracker.resultValues[title]); @@ -86,7 +91,7 @@ FilterTracker.prototype.processChanges = function(changes) { for(var t=0; t