mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Got sync to work
This commit is contained in:
parent
c1cb020283
commit
26d9b57923
@ -6,7 +6,7 @@ const { Header } = require('./Header.min.js');
|
||||
const { themeStyle } = require('../theme.js');
|
||||
const { _ } = require('lib/locale.js');
|
||||
|
||||
class OneDriveAuthScreenComponent extends React.Component {
|
||||
class OneDriveLoginScreenComponent extends React.Component {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@ -104,6 +104,6 @@ const mapStateToProps = (state) => {
|
||||
return {};
|
||||
};
|
||||
|
||||
const OneDriveAuthScreen = connect(mapStateToProps)(OneDriveAuthScreenComponent);
|
||||
const OneDriveLoginScreen = connect(mapStateToProps)(OneDriveLoginScreenComponent);
|
||||
|
||||
module.exports = { OneDriveAuthScreen };
|
||||
module.exports = { OneDriveLoginScreen };
|
@ -4,7 +4,7 @@ const { createStore } = require('redux');
|
||||
const { connect, Provider } = require('react-redux');
|
||||
|
||||
const { MainScreen } = require('./MainScreen.min.js');
|
||||
const { OneDriveAuthScreen } = require('./OneDriveAuthScreen.min.js');
|
||||
const { OneDriveLoginScreen } = require('./OneDriveLoginScreen.min.js');
|
||||
const { Navigator } = require('./Navigator.min.js');
|
||||
|
||||
const { app } = require('../app');
|
||||
@ -51,7 +51,7 @@ class RootComponent extends React.Component {
|
||||
|
||||
const screens = {
|
||||
Main: { screen: MainScreen },
|
||||
OneDriveAuth: { screen: OneDriveAuthScreen },
|
||||
OneDriveLogin: { screen: OneDriveLoginScreen },
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -19,11 +19,8 @@ class SideBarComponent extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
sync_click() {
|
||||
this.props.dispatch({
|
||||
type: 'NAV_GO',
|
||||
routeName: 'OneDriveAuth',
|
||||
});
|
||||
async sync_click() {
|
||||
await shared.synchronize_press(this);
|
||||
}
|
||||
|
||||
folderItem(folder, selected) {
|
||||
|
@ -182,13 +182,13 @@ class BaseApplication {
|
||||
|
||||
reducerActionToString(action) {
|
||||
let o = [action.type];
|
||||
if (action.id) o.push(action.id);
|
||||
if (action.noteId) o.push(action.noteId);
|
||||
if (action.folderId) o.push(action.folderId);
|
||||
if (action.tagId) o.push(action.tagId);
|
||||
if (action.tag) o.push(action.tag.id);
|
||||
if (action.folder) o.push(action.folder.id);
|
||||
if (action.notesSource) o.push(JSON.stringify(action.notesSource));
|
||||
if ('id' in action) o.push(action.id);
|
||||
if ('noteId' in action) o.push(action.noteId);
|
||||
if ('folderId' in action) o.push(action.folderId);
|
||||
if ('tagId' in action) o.push(action.tagId);
|
||||
if ('tag' in action) o.push(action.tag.id);
|
||||
if ('folder' in action) o.push(action.folder.id);
|
||||
if ('notesSource' in action) o.push(JSON.stringify(action.notesSource));
|
||||
return o.join(', ');
|
||||
}
|
||||
|
||||
@ -239,6 +239,7 @@ class BaseApplication {
|
||||
this.store_ = createStore(this.reducer, applyMiddleware(this.generalMiddleware()));
|
||||
BaseModel.dispatch = this.store().dispatch;
|
||||
FoldersScreenUtils.dispatch = this.store().dispatch;
|
||||
reg.dispatch = this.store().dispatch;
|
||||
}
|
||||
|
||||
async start(argv) {
|
||||
|
@ -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;
|
@ -105,32 +105,8 @@ class SideMenuContentComponent extends Component {
|
||||
}
|
||||
|
||||
async synchronize_press() {
|
||||
const action = this.props.syncStarted ? 'cancel' : 'start';
|
||||
|
||||
if (Setting.value('sync.target') == Setting.SYNC_TARGET_ONEDRIVE && !reg.oneDriveApi().auth()) {
|
||||
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'NAV_GO',
|
||||
routeName: 'OneDriveLogin',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (action == 'cancel') {
|
||||
sync.cancel();
|
||||
} else {
|
||||
reg.scheduleSync(0);
|
||||
}
|
||||
const actionDone = await shared.synchronize_press(this);
|
||||
if (actionDone === 'auth') this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||
}
|
||||
|
||||
folderItem(folder, selected) {
|
||||
|
Loading…
Reference in New Issue
Block a user