TW5 get changed tiddlers

131 views
Skip to first unread message

Danielo Rodríguez

unread,
Oct 4, 2015, 11:17:35 AM10/4/15
to TiddlyWiki
Hello,

I think I can remember a function that returns the tiddlers that have changed since the wiki has loaded.

I can see a wiki.changeCount object. Is that the intended way knowing it? Is there any side effect if I manually empty that object?

Thanks in advance.

Jeremy Ruston

unread,
Oct 4, 2015, 11:37:08 AM10/4/15
to tiddl...@googlegroups.com
Hi Danielo

I think I can remember a function that returns the tiddlers that have changed since the wiki has loaded.

I can see a wiki.changeCount object. Is that the intended way knowing it? Is there any side effect if I manually empty that object?

The wiki store keeps track of a changecount for each tiddler title. It is used by the sync object to track changes to the store, amongst other things. Resetting it would break the expectation that the changecount for a tiddler can only increase, and never decrease.

What are you trying to accomplish?

Best wishes

Jeremy.



Thanks in advance.

--
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/55d2db4b-3bad-40b6-a66d-ff15235f61a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Danielo Rodríguez

unread,
Oct 5, 2015, 3:54:40 AM10/5/15
to TiddlyWiki
Hello Jeremy


El domingo, 4 de octubre de 2015, 17:37:08 (UTC+2), Jeremy Ruston escribió:
 
The wiki store keeps track of a changecount for each tiddler title. It is used by the sync object to track changes to the store, amongst other things.

That is exactly the functionality that I wanted 
 
Resetting it would break the expectation that the changecount for a tiddler can only increase, and never decrease.

I was guessing that, thanks for confirmation.
 
What are you trying to accomplish?

Basically I want to know which tiddlers has changes since the last time I extracted the changed tiddlers and saved in a remote place. I think I can just copy the object each time I want to "commit" and compare it with the previous values, and get only those that have an higher value.

Regards 

Jeremy Ruston

unread,
Oct 5, 2015, 5:00:56 AM10/5/15
to tiddl...@googlegroups.com
Hi Danielo

Basically I want to know which tiddlers has changes since the last time I extracted the changed tiddlers and saved in a remote place. I think I can just copy the object each time I want to "commit" and compare it with the previous values, and get only those that have an higher value.

The sync mechanism handles this by keeping track of the last change count it’s seen for each tiddler title.

Best wishes

Jeremy.


Regards 

--
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.

Danielo Rodríguez

unread,
Oct 5, 2015, 6:05:58 AM10/5/15
to TiddlyWiki

The sync mechanism handles this by keeping track of the last change count it’s seen for each tiddler title.

Best wishes

Jeremy.

Hello Jeremy,

Thank you, that is what I'm going to do. Which part of the sync mechanism tracks this? I suppose it is not any sync adapter, it is directly managed by sync daemon right? I can see that it works on the single file  (standalone) version. Seems like the "tracking" is boot based.
 I mean, it tracks changes since boo, and they are reset on each boot. But there is something that puzzles me a bit, and is the way the numbers increases. For example, if you go to tiddlywiki.com and opens the console, then you get this:

$tw.wiki.changeCount
Object {$:/StoryList: 1, $:/HistoryList: 1}

So far so good. Then, if I change the Hello there tiddler (edit -> add content -> save) the count increases on a weird way:

$tw.wiki.changeCount
Object 
  1. $:/HistoryList3
  2. $:/StoryList3
  3. $:/state/popup/more--12116254872
  4. $:/state/popup/tiddler-info--17790556972
  5. Draft of 'HelloThere'10
  6. HelloThere1

Why there are 10 changes to the Draft of 'HelloThere' ? and that number always increases, but the Draft tiddler does not exists anymore. Then, how can I know which tiddlers exists and which ones does not?

Regards

Danielo Rodríguez

unread,
Oct 5, 2015, 6:12:28 AM10/5/15
to TiddlyWiki
According to wiki.js code:

* `changedTiddlers` is a hashmap describing changes to named tiddlers since wiki change events were last dispatched. Each entry is a hashmap containing two fields:
modified: true/false
deleted: true/false


But the changedTiddlers object is always empty.

Jeremy Ruston

unread,
Oct 5, 2015, 11:09:06 AM10/5/15
to tiddl...@googlegroups.com
Hi Danielo

So far so good. Then, if I change the Hello there tiddler (edit -> add content -> save) the count increases on a weird way:

$tw.wiki.changeCount
Object 
  1. $:/HistoryList3
  2. $:/StoryList3
  3. $:/state/popup/more--12116254872
  4. $:/state/popup/tiddler-info--17790556972
  5. Draft of 'HelloThere'10
  6. HelloThere: 1
Why there are 10 changes to the Draft of 'HelloThere' ? and that number always increases, but the Draft tiddler does not exists anymore. Then, how can I know which tiddlers exists and which ones does not?

The changecount is not reset when a tiddler is deleted. Otherwise it wouldn’t be possible to distinguish between a tiddler that was reset and recreated, and one that hasn’t. Those 10 changes to the draft correspond to the characters you typed.

So if you want to know whether a tiddler exists you’d call store.tiddlerExists(title) in the usual way.

> But the changedTiddlers object is always empty.

You’re not supposed to touch that object directly. Information derived from it is passed to change events automatically.

Best wishes

Jeremy


Regards

--
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.

Danielo Rodríguez

unread,
Oct 5, 2015, 11:29:04 AM10/5/15
to TiddlyWiki
You’re not supposed to touch that object directly. Information derived from it is passed to change events automatically.

Best wishes

Jeremy

The change events format is exactly what I was looking for. The only problem is that they are events, and I want to extract the information on user interaction. I think the best way is to mimic the behavior of the change daemon, but I would like to avoid duplicating stuff. Where can I find the daemon that triggers the change events?

Jeremy Ruston

unread,
Oct 5, 2015, 11:32:01 AM10/5/15
to tiddl...@googlegroups.com
Hi Danielo

The change events format is exactly what I was looking for. The only problem is that they are events, and I want to extract the information on user interaction. I think the best way is to mimic the behavior of the change daemon, but I would like to avoid duplicating stuff. Where can I find the daemon that triggers the change events?

I’m not sure what you mean. When a change is registered in the store, we queue an event an dispatch it via nextTick().

Perhaps you can explain a little about what you are trying to accomplish?

Best wishes

Jeremy.



--
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.

Danielo Rodríguez

unread,
Oct 5, 2015, 11:34:03 AM10/5/15
to TiddlyWiki
Those 10 changes to the draft correspond to the characters you typed.

I think is actually 8 + 1 when entering in edit mode and +1 when clicking save 


 
So if you want to know whether a tiddler exists you’d call store.tiddlerExists(title) in the usual way.

That would be definetively helpful.

Regards 

Danielo Rodríguez

unread,
Oct 5, 2015, 12:32:49 PM10/5/15
to TiddlyWiki
I’m not sure what you mean. When a change is registered in the store, we queue an event an dispatch it via nextTick().

Perhaps you can explain a little about what you are trying to accomplish?

It is quite easy, let me explain it well.

I want to allow the user make all the changes he/she wants to the wiki. Then, when he cliks one button, I want to generate a report with the tiddlers that have been changed for the running sesion. Creation, deletion and update. At that point, if the user decides to "save" those changes, the "sessions" should be reset, and when the user clicks again, then the report will only include the changes made since the last time he checked the report.

Does that make sense 

Jeremy Ruston

unread,
Oct 6, 2015, 9:24:27 AM10/6/15
to tiddl...@googlegroups.com
Hi Danielo

I want to allow the user make all the changes he/she wants to the wiki. Then, when he cliks one button, I want to generate a report with the tiddlers that have been changed for the running sesion. Creation, deletion and update. At that point, if the user decides to "save" those changes, the "sessions" should be reset, and when the user clicks again, then the report will only include the changes made since the last time he checked the report.

So, at startup, and each time the user clicks the button, you’d scan the changecounts of all the tiddlers in the store, and compare against the record you kept from the last check. The difference tells you which tiddlers have changed. You don’t need to change anything in the store; you just need to keep track of the last change count you’ve seen for each tiddler you are processing.

Best wishes

Jeremy.



Does that make sense 

--
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.

Danielo Rodríguez

unread,
Oct 6, 2015, 10:24:57 AM10/6/15
to TiddlyWiki
So, at startup, and each time the user clicks the button, you’d scan the changecounts of all the tiddlers in the store, and compare against the record you kept from the last check. The difference tells you which tiddlers have changed. You don’t need to change anything in the store; you just need to keep track of the last change count you’ve seen for each tiddler you are processing.

Best wishes

Jeremy.

That is exactly what I'm going to do. Thank you very much.

Regards 
Reply all
Reply to author
Forward
0 new messages