From 854e8d7083f806e861697f65dc4550c4c31b1bd8 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 16 Mar 2013 10:50:36 +0000 Subject: [PATCH] Use the wiki event mechanism to dispatch lazyLoad notifications to syncers We're trying to get to the point where wiki.js doesn't know about syncers --- core/modules/wiki.js | 4 ++-- plugins/tiddlywiki/tiddlyweb/tiddlyweb.js | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/modules/wiki.js b/core/modules/wiki.js index ddb841321..ffa93bb73 100644 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -628,8 +628,8 @@ exports.getTiddlerText = function(title,defaultText) { // Just return the text if we've got it return tiddler.fields.text; } else { - // Ask all the syncers to load the tiddler if they can - this.invokeSyncers("lazyLoad",title,tiddler); + // Tell any listeners about the need to lazily load this tiddler + this.dispatchEvent("lazyLoad",title); // Indicate that the text is being loaded return null; } diff --git a/plugins/tiddlywiki/tiddlyweb/tiddlyweb.js b/plugins/tiddlywiki/tiddlyweb/tiddlyweb.js index 48158d7d3..f74bdf0a1 100644 --- a/plugins/tiddlywiki/tiddlyweb/tiddlyweb.js +++ b/plugins/tiddlywiki/tiddlyweb/tiddlyweb.js @@ -89,6 +89,10 @@ var TiddlyWebSyncer = function(options) { this.wiki.addEventListener("change",function(changes) { self.syncToServer(changes); }); + // Listen out for lazyLoad events + this.wiki.addEventListener("lazyLoad",function(title) { + self.lazyLoad(title); + }); this.log("Initialising with host:",this.host); // Get the login status this.getStatus(function (err,isLoggedIn,json) { @@ -126,7 +130,7 @@ TiddlyWebSyncer.prototype.log = function(/* arguments */) { /* Lazily load a skinny tiddler if we can */ -TiddlyWebSyncer.prototype.lazyLoad = function(title,tiddler) { +TiddlyWebSyncer.prototype.lazyLoad = function(title) { // Queue up a sync task to load this tiddler this.enqueueSyncTask({ type: "load",