Is there any way refresh delay could be implemented as a setting of the edit-text widget?
if(!tiddler || !tiddler.hasField("draft.of") || !tiddler.hasField("refresh.slow")) {
However, based on a quick look at the code, I can speculate about two ways of implementing this change that do not involve storing editor state in the widget tree:
- Have a field other than "draft.of" which marks a tiddler as a "draft" for the purposes of refresh time.
- Modify the "change" event listener receive an optional parameter for the timeout associated with any given change, allowing any source of changes to define its own timeout value.
#1 could be implemented quickly by changing this line of the render code to something like:
if(!tiddler || !tiddler.hasField("draft.of") || !tiddler.hasField("refresh.slow")) {
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d1e6e6e0-7b4e-4b15-aa3e-8a49afb83a06%40googlegroups.com.
The other day I picked through the code to ascertain what would be necessary to implement a refresh delay setting in $edit-text and friends.
- State Modifying Widgets
- Add a new "delay" property, and possibly means to fall back to default values
- Store this property in the AddTiddler hashmap
- AddTiddler microkernel function
- Extract the delay property from the hashmap argument
- Pass the property to enqueueTiddlerEvent
- enqueueTiddlerEvent wiki.js function
- Accept the delay property as a third argument
- Add this property to the data for the change event
- - "change" event handler
- Extract the delay property from the event argument and schedule delay
One nice thing about this approach is that it would no longer be necessary to check for draft tiddlers in the change event handler -- instead, the editor widgets in the EditTemplate would simply assign a delay value.
Probably the most obtrusive element of this solution is that the parameter of the change event would need to be redefined as a hashmap... It looks as if there is a lot of code that handles that event, and I don't know enough about TiddlyWiki to identify other possible datapaths for the delay variable.
If multiple change events are aggregated, it would be sensible to use the lowest delay value associated with any of them for scheduling purposes.
...Anyway, at this point I'm feeling as if I could try my hand at this modification -- but I might end up out of my depth as I'm not a JavaScript expert. Jeremy, let me know if this scheme sounds remotely sensible.
What would it do if the same tiddler were written twice with different delays specified?
- The user's direct interaction initiates all changes to the state of the tiddler store -- or at least the vast majority of changes.
- The user's interaction with editor widgets can change the state of at most one tiddler at a time. (I understand this does not apply to triggering widgets!)
You make a strong case that editor widgets should not have state independent of the store, to avoid conflicts in or loss of data. This makes sense to me. I also agree that delay is a feature of the interface / UX design, and it is my view that the degree of delay should be a function of the means by which the information is changed, rather than what information is changed -- hence the proposal that it be a feature of the instigating widgets.
The question then becomes how the editor widgets can communicate to the renderer that the changes they have instigated should be delayed. There needs to be a means of associating the changes (which the renderer receives as event notifications from the store) with the specific source and delay value. If assumption 2 is correct, only a single delay value need be set per change.
I can see people focusing on delaying the write to the tiddler store where the actual problem, in my opinion, is the refresh of the widget tree.From my point of view, for consistency we should keep the changes to the tiddler store immediate, and focus in adding a delay to the refresh mechanism.
Here's how I would interpret possible refresh-delay settings...
delay: 300ms
- after an update, do not refresh for 300ms
- after those 300ms only refresh so long as the triggering widget did not fire another refresh event
max-delay: 2s
- if the user has managed to accumulate delays for 2s, do a refresh anyway
Best wishes,— tb
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/812f1bbd-c354-41d6-af96-795d2fcc3157%40googlegroups.com.
I'd urge you to examine the implementation of the existing refresh dampening mechanism:
So, what could be done is extending these bits so as to:
- also delay refreshing for (certain, perhaps state / temp) tiddlers instead of just drafts, e.g. those storing a search-terms
- those tiddlers could perhaps simply have a tag $:/tags/DelayRefresh or some field tw-refresh-delay:2
- implement a max-refresh-delay
- seems rather straight forward, using two timers eventually canceling each other out
- the max-timer not being cleared, though
Do you see problems with 1. or 2.?Best wishes,— tb
I'd urge you to examine the implementation of the existing refresh dampening mechanism:
https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/startup/render.js
<$edit-text field="foo"/>
...how come this delay works well with the preview in edit mode
but not when I edit a field of the current tiddler in view-mode?
Because the mechanism works on draft tiddlers, and there’s no draft tiddler involved when you use the edit-text widget directly.
So, could we perhaps introduce a single state tiddler to...
- store the information of any edit-text widget instance given focus
- store the text being edited in it
- only commit the text back to the tiddler (field) after the edit delay passed?
Best wishes,— tb--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/200f09a2-4450-4b3a-94b5-6cf6b86b4aa0%40googlegroups.com.
We’ve discussed this before: it’s why the existing mechanism defers the refresh cycle, and doesn’t try to defer updating the value of the tiddler.
Hi Jeremy,We’ve discussed this before: it’s why the existing mechanism defers the refresh cycle, and doesn’t try to defer updating the value of the tiddler.
--If we managed to dynamically rebind the input to a state tiddler during editing — rather than the tiddler which we look at — then no refresh of the tiddler we look at should take place (while typing). But yes, the moment after the delay when we refresh the current tiddler we still have the problem of re-focusing the widget that got destroyed at the position we were when editing. However (!), the state tiddler that we use to store the edited text could (perhaps) via some qualify identifier be used to store a reference to the editing widget and thus a widget could check upon creation if it is that widget and steal the focus back.Best wishes,— tb
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/hlIvXE6jRys/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/c14303fa-7379-4f19-bb34-53766451dee4%40googlegroups.com.