Add global setting to enable filter observation

This commit is contained in:
Jeremy Ruston
2025-05-07 20:49:57 +01:00
parent 3f733796e5
commit 728243a66a
4 changed files with 14 additions and 0 deletions
@@ -5,6 +5,11 @@ list-after: $:/plugins/tiddlywiki/internals/filterinspection/InspectResultsTab
Log traces of this filter expression in the background. A trace will be generated every time the filter is evaluated, regardless of the context. The trace is only saved if the results are different from previous traces.
<$checkbox tiddler="$:/config/FilterObservationionEnabled" field="text" checked="yes" unchecked="no" default="no">
Enable background filter observation
</$checkbox>
<$button>
<%if [all[shadows+tiddlers]tag[$:/tags/InspectableFilter]get[text]match{$:/temp/advancedsearch}count[]match[0]] %>
<$action-createtiddler $basetitle="$:/config/inspectable-filters/filter" tags="$:/tags/InspectableFilter" type="text/plain" text={{$:/temp/advancedsearch}}/>
@@ -25,6 +25,10 @@ exports.startup = function() {
var accumulator = [];
// Add our hook for each filter evaluation
$tw.hooks.addHook("th-filter-evaluation",function(filterString,wrappers) {
// Check that filter observation is enabled
if($tw.wiki.getTiddlerText("$:/config/FilterObservationionEnabled","no") !== "yes") {
return wrappers;
}
// Get the list of filters to be inspected
var inspectedFilters = [];
$tw.wiki.eachTiddlerPlusShadows(function(tiddler,title) {
@@ -0,0 +1,3 @@
title: $:/temp/advancedsearch
[all[shadows+tiddlers]tag[HelloThere]] -[all[shadows+tiddlers]prefix[A]] :filter[<currentTiddler>tag[Community]]
@@ -0,0 +1,2 @@
title: $:/config/FilterObservationionEnabled
text: yes