1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Got sync to work

This commit is contained in:
Laurent Cozic
2017-11-06 21:11:15 +00:00
parent c1cb020283
commit 26d9b57923
6 changed files with 49 additions and 43 deletions

View File

@ -20,4 +20,36 @@ shared.renderTags = function(props, renderItem) {
return tagItems;
}
shared.synchronize_press = async function(comp) {
const { Setting } = require('lib/models/setting.js');
const { reg } = require('lib/registry.js');
const action = comp.props.syncStarted ? 'cancel' : 'start';
if (Setting.value('sync.target') == Setting.SYNC_TARGET_ONEDRIVE && !reg.oneDriveApi().auth()) {
comp.props.dispatch({
type: 'NAV_GO',
routeName: 'OneDriveLogin',
});
return 'auth';
}
let sync = null;
try {
sync = await reg.synchronizer(Setting.value('sync.target'))
} catch (error) {
reg.logger().info('Could not acquire synchroniser:');
reg.logger().info(error);
return 'error';
}
if (action == 'cancel') {
sync.cancel();
return 'cancel';
} else {
reg.scheduleSync(0);
return 'sync';
}
}
module.exports = shared;