mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-14 13:51:24 +00:00
Rejigging syncer structuring
The goal is to separate out the saver handling from the syncadaptor handling; it will take a few steps to get there
This commit is contained in:
@@ -62,8 +62,17 @@ exports.startup = function() {
|
||||
document: document
|
||||
});
|
||||
}
|
||||
// Find a working syncadaptor
|
||||
$tw.syncadaptor = undefined;
|
||||
$tw.modules.forEachModuleOfType("syncadaptor",function(title,module) {
|
||||
if(!$tw.syncadaptor && module.adaptorClass) {
|
||||
$tw.syncadaptor = new module.adaptorClass({wiki: $tw.wiki});
|
||||
}
|
||||
});
|
||||
// Set up the syncer object
|
||||
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki});
|
||||
if($tw.syncadaptor) {
|
||||
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki, syncadaptor: $tw.syncadaptor});
|
||||
}
|
||||
// Host-specific startup
|
||||
if($tw.browser) {
|
||||
// Install the popup manager
|
||||
|
||||
@@ -14,20 +14,15 @@ The syncer tracks changes to the store. If a syncadaptor is used then individual
|
||||
|
||||
/*
|
||||
Instantiate the syncer with the following options:
|
||||
syncadaptor: reference to syncadaptor to be used
|
||||
wiki: wiki to be synced
|
||||
*/
|
||||
function Syncer(options) {
|
||||
var self = this;
|
||||
this.wiki = options.wiki;
|
||||
this.syncadaptor = options.syncadaptor
|
||||
// Make a logger
|
||||
this.logger = new $tw.utils.Logger("syncer" + ($tw.browser ? "-browser" : "") + ($tw.node ? "-server" : ""));
|
||||
// Find a working syncadaptor
|
||||
this.syncadaptor = undefined;
|
||||
$tw.modules.forEachModuleOfType("syncadaptor",function(title,module) {
|
||||
if(!self.syncadaptor && module.adaptorClass) {
|
||||
self.syncadaptor = new module.adaptorClass(self);
|
||||
}
|
||||
});
|
||||
// Initialise our savers
|
||||
if($tw.browser) {
|
||||
this.initSavers();
|
||||
@@ -603,6 +598,8 @@ Syncer.prototype.dispatchTask = function(task,callback) {
|
||||
}
|
||||
// Invoke the callback
|
||||
callback(null);
|
||||
},{
|
||||
tiddlerInfo: self.tiddlerInfo[task.title]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user