Button and Filter Inefficiencies

104 views
Skip to first unread message

David Allen

unread,
Dec 25, 2017, 12:18:00 AM12/25/17
to TiddlyWiki
Hey everyone!  I have buttons that, when clicked, set a field in a tiddler using a filter that sorts through six thousand tiddlers.  The buttons responsible for this are slowing down my wiki considerably.

Here's the code for the buttons I use
<$button to="Good Tumblr" class="tab_button">Good
<<set_timefields>>

<$set name="goods" filter="[tag[tumblr]!year{Sandbox_Retrieve!!year}] [tag[tumblr]year{Sandbox_Retrieve!!year}!month{Sandbox_Retrieve!!month}]+[category[good]!prefix[Template]sort[modified]!has[format]!has[improve]limit[5]]">

<$action-setfield $tiddler="Sandbox_Retrieve" $field="goods" $value=<<goods>> />

</$set>

</$button>




I have some pages that have several of these buttons on a page at one time, and these slow the wiki more than others.  Can anyone tell me if there's something I can do to speed up my wiki? Thanks!

TonyM

unread,
Dec 25, 2017, 2:03:59 AM12/25/17
to TiddlyWiki
David,

Can you selectively show these buttons only if some other condition is true on each tiddler such as a specific tag. To do this place a tiddler in the view template with the viewtemplate tag and test for the specific tag 1st.

You could even add a checkbox to toggle the specific tag only when needed?

Best of luck
The Australian follow the sun community member.

Regards
Tony

David Allen

unread,
Dec 25, 2017, 5:43:27 PM12/25/17
to TiddlyWiki
So here's what I've tried so far:

<$select tiddler="Sandbox_Retrieve" field="current_mode">
<option>add</option>
<option>good</option>
<option>bad</option>
<option>new</option>
<option>reverse</option>
</$select>

<$reveal state={{!!Sandbox_Retrieve!!current_mode}} type="match" text="good">
<$button to="Good Tumblr" class="tab_button">Good
<<set_timefields>>

<$set name="goods" filter="[tag[tumblr]!year{Sandbox_Retrieve!!year}] [tag[tumblr]year{Sandbox_Retrieve!!year}!month{Sandbox_Retrieve!!month}]+[category[good]!prefix[Template]sort[modified]!has[format]!has[improve]limit[5]]">

<$action-setfield $tiddler="Sandbox_Retrieve" $field="goods" $value=<<goods>> />

</$set>

</$button>
</$reveal>
For whatever reason this isn't working.  I think I've got something wrong with the reveal widget but I'm not sure what.

Eric Shulman

unread,
Dec 25, 2017, 6:04:28 PM12/25/17
to TiddlyWiki
On Monday, December 25, 2017 at 2:43:27 PM UTC-8, David Allen wrote:
<$reveal state={{!!Sandbox_Retrieve!!current_mode}} type="match" text="good">
For whatever reason this isn't working.  I think I've got something wrong with the reveal widget but I'm not sure what.

The "state" param is a TextReference, so you don't need the surrounding {{..}}.  Also, you've got an extra leading "!!".

Try this:
<$reveal state="Sandbox_Retrieve!!current_mode" type="match" text="good">


enjoy,
-e

David Allen

unread,
Dec 25, 2017, 6:20:03 PM12/25/17
to TiddlyWiki
That's helped to a degree, but I'm wondering if I could modify the code somehow to prevent the filter from being evaluated until the button is pressed?


On Sunday, December 24, 2017 at 11:18:00 PM UTC-6, David Allen wrote:

Eric Shulman

unread,
Dec 25, 2017, 7:42:39 PM12/25/17
to TiddlyWiki
On Monday, December 25, 2017 at 3:20:03 PM UTC-8, David Allen wrote:
That's helped to a degree, but I'm wondering if I could modify the code somehow to prevent the filter from being evaluated until the button is pressed?

Use the $button params set and setTo to change a flag value... then, use a $reveal wrapped around the costly $set and $action-setfield code, so that it is only rendered after the button is pressed.  Try the following code and let me know if it works for your use-case.

-e

<$button to="Good Tumblr" set="Sandbox_Retrieve!!calcfilter" setTo="show" class="tab_button">Good
<
<set_timefields>>

<$reveal state="Sandbox_Retrieve!!calcfilter" type="match" text="show">


<$set name="goods" filter="[tag[tumblr]!year{Sandbox_Retrieve!!year}] [tag[tumblr]year{Sandbox_Retrieve!!year}!month{Sandbox_Retrieve!!month}]+[category[good]!prefix[Template]sort[modified]!has[format]!has[improve]limit[5]]">
<$action-setfield $tiddler="Sandbox_Retrieve" $field="goods" $value=<
<goods>> />
</$set>

</$reveal>

</$button>

Message has been deleted

David Allen

unread,
Dec 25, 2017, 9:51:53 PM12/25/17
to TiddlyWiki
So I figured out a way to get this to work.

/define some_macro()
<<set_timefields>>
<$set ..... >
<$action-setfield .....>
/
end

<$button actions=<<some_macro>> to="destination" class="blah">
Button Title
</$button>
By shoving the costly set code into a macro, I prevented it from being rendered until the button is actually clicked.  So much faster now!



On Sunday, December 24, 2017 at 11:18:00 PM UTC-6, David Allen wrote:
Reply all
Reply to author
Forward
0 new messages