1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Sync when changing note or folder

This commit is contained in:
Laurent Cozic 2017-07-24 21:36:49 +01:00
parent cfa3c6f4bb
commit fc7163b324
4 changed files with 35 additions and 7 deletions

View File

@ -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();

View File

@ -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"
},

View File

@ -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');

View File

@ -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) => {