diff --git a/CliClient/app/app.js b/CliClient/app/app.js index aea29eb48..0fa395d09 100644 --- a/CliClient/app/app.js +++ b/CliClient/app/app.js @@ -258,6 +258,20 @@ class Application { }); } + baseModelListener(action) { + switch (action.type) { + + case 'NOTES_UPDATE_ONE': + case 'NOTES_DELETE': + case 'FOLDERS_UPDATE_ONE': + case 'FOLDER_DELETE': + + reg.scheduleSync(); + break; + + } + } + async start() { this.vorpal_ = require('vorpal')(); vorpalUtils.initialize(this.vorpal()); @@ -285,7 +299,7 @@ class Application { this.logger_.setLevel(initArgs.logLevel); reg.setLogger(this.logger_); - reg.dispatch = (o) => {} + reg.dispatch = (o) => {}; this.dbLogger_.addTarget('file', { path: profileDir + '/log-database.txt' }); this.dbLogger_.setLevel(initArgs.logLevel); @@ -300,6 +314,7 @@ class Application { reg.setDb(this.database_); BaseModel.db_ = this.database_; + BaseModel.dispatch = (action) => { this.baseModelListener(action) } await Setting.load(); @@ -322,8 +337,8 @@ class Application { } else { setInterval(() => { - reg.scheduleSync(1); - }, 1000 * 5);//60 * 5); + reg.scheduleSync(0); + }, 1000 * 60 * 5); this.updatePrompt(); this.vorpal().show(); diff --git a/CliClient/package.json b/CliClient/package.json index b6e82245b..216396f37 100644 --- a/CliClient/package.json +++ b/CliClient/package.json @@ -7,7 +7,7 @@ "url": "https://github.com/laurent22/joplin" }, "url": "git://github.com/laurent22/joplin.git", - "version": "0.8.63", + "version": "0.8.65", "bin": { "joplin": "./main_launcher.js" }, diff --git a/ReactNativeClient/lib/models/setting.js b/ReactNativeClient/lib/models/setting.js index a0649ced9..dd09d8f78 100644 --- a/ReactNativeClient/lib/models/setting.js +++ b/ReactNativeClient/lib/models/setting.js @@ -43,6 +43,13 @@ class Setting extends BaseModel { this.cache_ = []; return this.modelSelectAll('SELECT * FROM settings').then((rows) => { this.cache_ = rows; + + // TEMPORARY TO CONVERT ALL CLIENT SETTINGS + for (let i = 0; i < this.cache_.length; i++) { + if (this.cache_[i].key == 'sync.target' && this.cache_[i].value == 'onedrive') { + this.cache_[i].value = 3; + } + } }); } @@ -223,7 +230,7 @@ Setting.metadata_ = { 'activeFolderId': { value: '', type: 'string', public: false }, 'sync.2.path': { value: '', type: 'string', public: true, appTypes: ['cli'] }, 'sync.3.auth': { value: '', type: 'string', public: false }, - 'sync.target': { value: 'onedrive', type: 'enum', public: true, label: () => _('Synchronisation target'), options: () => { + 'sync.target': { value: Setting.SYNC_TARGET_ONEDRIVE, type: 'enum', public: true, label: () => _('Synchronisation target'), options: () => { let output = {}; output[Setting.SYNC_TARGET_MEMORY] = 'Memory'; output[Setting.SYNC_TARGET_FILESYSTEM] = _('File system'); diff --git a/ReactNativeClient/lib/registry.js b/ReactNativeClient/lib/registry.js index b247ccca4..56b2ac236 100644 --- a/ReactNativeClient/lib/registry.js +++ b/ReactNativeClient/lib/registry.js @@ -106,7 +106,7 @@ reg.scheduleSync = async (delay = null) => { reg.logger().info('Scheduling sync operation...'); - reg.scheduleSyncId_ = setTimeout(async () => { + const timeoutCallback = async () => { reg.scheduleSyncId_ = null; reg.logger().info('Doing scheduled sync'); @@ -129,7 +129,13 @@ reg.scheduleSync = async (delay = null) => { throw error; } } - }, delay); + }; + + if (delay === 0) { + timeoutCallback(); + } else { + reg.scheduleSyncId_ = setTimeout(timeoutCallback, delay); + } } reg.setDb = (v) => {