Refresh widget understanding

I’m using @saqimtiaz refresh widget in a macro in a template and the refresh is not working as expected. I wrapped the leafmap widget (leaflet plugin) that draws maps with the refresh widget. I made a change to an other tiddler and the map refreshed.

I was recently blocked from a map tile server because of this issue. I had changed a tiddler title that triggered the relink plugin to modify 50+ tiddlers causing an overwhelming number of refreshes of a map.

Hi @clsturgeon, can you share some code that shows how you used the widget?

I have ViewTemplate that, when tiddler is tagged “event” it will do this…

{{||$:/plugins/cls/mk/template/event}}

This tiddler has this macro…

\define mapping(title, maptype)
<$set name="sites" filter="""[tag[event]contains:event[$title$]each:list-item[place]has[point]]""" value="show" emptyValue="">
<$reveal text=<<sites>> type="match" default="show">
<$set name=one filter="[tag[event]contains:event[$title$]each:list-item[place]has[point]count[]]">
<$reveal text="1" default=<<one>> type=match>
<$refresh><$leafmap tileControl tile='$maptype$' places="""{"filter":"[tag[event]contains:event[$title$]each:list-item[place]has[point]]"}""" zoom='12' cluster='30' /></$refresh>
</$reveal>

<$reveal text="1" default=<<one>> type=nomatch>
<$refresh><$leafmap tileControl tile='$maptype$' places="""{"filter":"[tag[event]contains:event[$title$]each:list-item[place]has[point]]"}""" cluster='30' /></$refresh>
</$reveal>
</$set>
</$reveal>
</$set>
\end

This macro is used like this (this is not the entire tiddler content)…

<$reveal text="" type=match default={{$:/config/cls/collection!!default-leafmap}}>
<$macrocall $name=mapping title={{!!title}} maptype="osm" /></$reveal>
<$reveal text="" type=nomatch default={{$:/config/cls/collection!!default-leafmap}}>
<$macrocall $name=mapping title={{!!title}} maptype={{$:/config/cls/collection!!default-leafmap}} /></$reveal></$reveal>

The above does not prevent refreshes.

And… FYI I just tried this instead of the above (and it worked; the refresh prevented the update when I made a change to another tiddler)…

<$reveal text="" type=match default={{$:/config/cls/collection!!default-leafmap}}>
<$refresh><$macrocall $name=mapping title={{!!title}} maptype="osm" /></$refresh></$reveal>
<$reveal text="" type=nomatch default={{$:/config/cls/collection!!default-leafmap}}>
<$refresh><$macrocall $name=mapping title={{!!title}} maptype={{$:/config/cls/collection!!default-leafmap}} /></$refresh>
</$reveal></$reveal>

i.e. I wrapped the macrocall with the refresh widget as oppose to how it is used in the macro.

This would suggest that the <$refresh> in the macro is not being honoured in the macro.

Thoughts?

Thank you,

Craig

The refresh widget cannot prevent a refresh if one if its ancestors gets refreshed, it can only prevent refresh in its descendants. The text substitution in the macro is probably the reason the set widgets are refreshing and re-rendering, which leads to their children needing to be rendered again. I would recommend that you refactor to avoid text substitution, using variable references instead.

1 Like