You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
All: Started moving sync target logic under SyncTarget classes
This commit is contained in:
@@ -2,11 +2,16 @@ const { reg } = require('lib/registry.js');
|
||||
|
||||
class BaseSyncTarget {
|
||||
|
||||
constructor(db) {
|
||||
constructor(db, options = null) {
|
||||
this.db_ = db;
|
||||
this.synchronizer_ = null;
|
||||
this.initState_ = null;
|
||||
this.logger_ = null;
|
||||
this.options_ = options;
|
||||
}
|
||||
|
||||
option(name, defaultValue = null) {
|
||||
return this.options_ && (name in this.options_) ? this.options_[name] : defaultValue;
|
||||
}
|
||||
|
||||
logger() {
|
||||
@@ -37,6 +42,23 @@ class BaseSyncTarget {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
initFileApi() {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
fileApi() {
|
||||
if (this.fileApi_) return this.fileApi_;
|
||||
this.fileApi_ = this.initFileApi();
|
||||
return this.fileApi_;
|
||||
}
|
||||
|
||||
// Usually each sync target should create and setup its own file API via initFileApi()
|
||||
// but for testing purposes it might be convenient to provide it here so that multiple
|
||||
// clients can share and sync to the same file api (see test-utils.js)
|
||||
setFileApi(v) {
|
||||
this.fileApi_ = v;
|
||||
}
|
||||
|
||||
async synchronizer() {
|
||||
if (this.synchronizer_) return this.synchronizer_;
|
||||
|
||||
@@ -79,4 +101,6 @@ class BaseSyncTarget {
|
||||
|
||||
}
|
||||
|
||||
BaseSyncTarget.dispatch = (action) => {};
|
||||
|
||||
module.exports = BaseSyncTarget;
|
||||
Reference in New Issue
Block a user