diff --git a/CliClient/app/command-sync.js b/CliClient/app/command-sync.js
index 9744518c9..a58be4d73 100644
--- a/CliClient/app/command-sync.js
+++ b/CliClient/app/command-sync.js
@@ -4,6 +4,7 @@ import { _ } from 'lib/locale.js';
import { Setting } from 'lib/models/setting.js';
import { BaseItem } from 'lib/models/base-item.js';
import { vorpalUtils } from './vorpal-utils.js';
+import { Synchronizer } from 'lib/synchronizer.js';
const locker = require('proper-lockfile');
const fs = require('fs-extra');
@@ -74,7 +75,7 @@ class Command extends BaseCommand {
let options = {
onProgress: (report) => {
- let lines = sync.reportToLines(report);
+ let lines = Synchronizer.reportToLines(report);
if (lines.length) vorpalUtils.redraw(lines.join(' '));
},
onMessage: (msg) => {
diff --git a/ReactNativeClient/lib/components/side-menu-content.js b/ReactNativeClient/lib/components/side-menu-content.js
index 0cf115766..ea9465aa6 100644
--- a/ReactNativeClient/lib/components/side-menu-content.js
+++ b/ReactNativeClient/lib/components/side-menu-content.js
@@ -4,6 +4,7 @@ import { Log } from 'lib/log.js';
import { Note } from 'lib/models/note.js';
import { FoldersScreenUtils } from 'lib/components/screens/folders-utils.js'
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
+import { Synchronizer } from 'lib/synchronizer.js';
import { reg } from 'lib/registry.js';
import { _ } from 'lib/locale.js';
@@ -65,37 +66,22 @@ class SideMenuContentComponent extends Component {
NotesScreenUtils.openNoteList(folder.id);
}
- async synchronizer_progress(report) {
- const sync = await reg.synchronizer();
- let lines = sync.reportToLines(report);
- this.setState({ syncReportText: lines.join("\n") });
- }
-
- synchronizer_complete() {
- FoldersScreenUtils.refreshFolders();
- }
-
- async componentWillMount() {
- reg.dispatcher().on('synchronizer_progress', this.synchronizer_progress.bind(this));
- reg.dispatcher().on('synchronizer_complete', this.synchronizer_complete.bind(this));
- }
-
- componentWillUnmount() {
- reg.dispatcher().off('synchronizer_progress', this.synchronizer_progress.bind(this));
- reg.dispatcher().off('synchronizer_complete', this.synchronizer_complete.bind(this));
- }
-
async synchronize_press() {
- if (reg.oneDriveApi().auth()) {
- const sync = await reg.synchronizer()
- sync.start();
+ const sync = await reg.synchronizer()
+
+ if (this.props.syncStarted) {
+ sync.cancel();
} else {
- this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
-
- this.props.dispatch({
- type: 'Navigation/NAVIGATE',
- routeName: 'OneDriveLogin',
- });
+ if (reg.oneDriveApi().auth()) {
+ sync.start();
+ } else {
+ this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
+
+ this.props.dispatch({
+ type: 'Navigation/NAVIGATE',
+ routeName: 'OneDriveLogin',
+ });
+ }
}
}
@@ -116,9 +102,14 @@ class SideMenuContentComponent extends Component {
if (items.length) items.push(); // DIVIDER
- items.push(