mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-09-05 12:28:02 +00:00
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
This commit is contained in:
@@ -628,8 +628,8 @@ exports.getTiddlerText = function(title,defaultText) {
|
|||||||
// Just return the text if we've got it
|
// Just return the text if we've got it
|
||||||
return tiddler.fields.text;
|
return tiddler.fields.text;
|
||||||
} else {
|
} else {
|
||||||
// Ask all the syncers to load the tiddler if they can
|
// Tell any listeners about the need to lazily load this tiddler
|
||||||
this.invokeSyncers("lazyLoad",title,tiddler);
|
this.dispatchEvent("lazyLoad",title);
|
||||||
// Indicate that the text is being loaded
|
// Indicate that the text is being loaded
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -89,6 +89,10 @@ var TiddlyWebSyncer = function(options) {
|
|||||||
this.wiki.addEventListener("change",function(changes) {
|
this.wiki.addEventListener("change",function(changes) {
|
||||||
self.syncToServer(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);
|
this.log("Initialising with host:",this.host);
|
||||||
// Get the login status
|
// Get the login status
|
||||||
this.getStatus(function (err,isLoggedIn,json) {
|
this.getStatus(function (err,isLoggedIn,json) {
|
||||||
@@ -126,7 +130,7 @@ TiddlyWebSyncer.prototype.log = function(/* arguments */) {
|
|||||||
/*
|
/*
|
||||||
Lazily load a skinny tiddler if we can
|
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
|
// Queue up a sync task to load this tiddler
|
||||||
this.enqueueSyncTask({
|
this.enqueueSyncTask({
|
||||||
type: "load",
|
type: "load",
|
||||||
|
Reference in New Issue
Block a user