You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Moved sync scheduling to redux middleware
This commit is contained in:
@@ -31,7 +31,7 @@ class ActionButtonComponent extends React.Component {
|
||||
|
||||
newTodo_press() {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Note',
|
||||
noteId: null,
|
||||
folderId: this.props.parentFolderId,
|
||||
@@ -41,7 +41,7 @@ class ActionButtonComponent extends React.Component {
|
||||
|
||||
newNote_press() {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Note',
|
||||
noteId: null,
|
||||
folderId: this.props.parentFolderId,
|
||||
@@ -51,7 +51,7 @@ class ActionButtonComponent extends React.Component {
|
||||
|
||||
newFolder_press() {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Folder',
|
||||
folderId: null,
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ class NoteItemComponent extends Component {
|
||||
|
||||
noteItem_press(noteId) {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Note',
|
||||
noteId: noteId,
|
||||
});
|
||||
|
||||
@@ -69,12 +69,11 @@ class NoteListComponent extends Component {
|
||||
async todoCheckbox_change(itemId, checked) {
|
||||
let note = await Note.load(itemId);
|
||||
await Note.save({ id: note.id, todo_completed: checked ? time.unixMs() : 0 });
|
||||
reg.scheduleSync();
|
||||
}
|
||||
|
||||
listView_itemPress(noteId) {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Note',
|
||||
noteId: noteId,
|
||||
});
|
||||
|
||||
@@ -114,12 +114,12 @@ class ScreenHeaderComponent extends Component {
|
||||
}
|
||||
|
||||
backButton_press() {
|
||||
this.props.dispatch({ type: 'Navigation/BACK' });
|
||||
this.props.dispatch({ type: 'NAV_BACK' });
|
||||
}
|
||||
|
||||
searchButton_press() {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Search',
|
||||
});
|
||||
}
|
||||
@@ -132,21 +132,21 @@ class ScreenHeaderComponent extends Component {
|
||||
|
||||
log_press() {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Log',
|
||||
});
|
||||
}
|
||||
|
||||
status_press() {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Status',
|
||||
});
|
||||
}
|
||||
|
||||
config_press() {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Config',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,8 +66,6 @@ class FolderScreenComponent extends BaseScreenComponent {
|
||||
|
||||
try {
|
||||
folder = await Folder.save(folder, { userSideValidation: true });
|
||||
|
||||
reg.scheduleSync();
|
||||
} catch (error) {
|
||||
dialogs.error(this, _('The notebook could not be saved: %s', error.message));
|
||||
return;
|
||||
@@ -79,7 +77,7 @@ class FolderScreenComponent extends BaseScreenComponent {
|
||||
});
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Notes',
|
||||
folderId: folder.id,
|
||||
});
|
||||
|
||||
@@ -181,8 +181,6 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
});
|
||||
if (isNew) Note.updateGeolocation(note.id);
|
||||
this.refreshNoteMetadata();
|
||||
|
||||
reg.scheduleSync();
|
||||
}
|
||||
|
||||
async saveOneProperty(name, value) {
|
||||
@@ -204,8 +202,6 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
lastSavedNote: Object.assign({}, note),
|
||||
note: note,
|
||||
});
|
||||
|
||||
reg.scheduleSync();
|
||||
} else {
|
||||
note[name] = value;
|
||||
this.setState({ note: note });
|
||||
@@ -224,12 +220,10 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
await Note.delete(note.id);
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Notes',
|
||||
folderId: folderId,
|
||||
});
|
||||
|
||||
reg.scheduleSync();
|
||||
}
|
||||
|
||||
attachFile_onPress() {
|
||||
@@ -274,7 +268,6 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
async todoCheckbox_change(checked) {
|
||||
await this.saveOneProperty('todo_completed', checked ? time.unixMs() : 0);
|
||||
reg.scheduleSync();
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -485,8 +478,6 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
note: note,
|
||||
folder: folder,
|
||||
});
|
||||
|
||||
reg.scheduleSync();
|
||||
}
|
||||
}}
|
||||
menuOptions={this.menuOptions()}
|
||||
|
||||
@@ -64,11 +64,9 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
|
||||
Folder.delete(folderId).then(() => {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Welcome',
|
||||
});
|
||||
|
||||
reg.scheduleSync();
|
||||
}).catch((error) => {
|
||||
alert(error.message);
|
||||
});
|
||||
@@ -77,7 +75,7 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
|
||||
editFolder_onPress(folderId) {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Folder',
|
||||
folderId: folderId,
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ class OneDriveLoginScreenComponent extends BaseScreenComponent {
|
||||
|
||||
try {
|
||||
await reg.oneDriveApi().execTokenRequest(this.authCode_, this.redirectUrl(), true);
|
||||
this.props.dispatch({ type: 'Navigation/BACK' });
|
||||
this.props.dispatch({ type: 'NAV_BACK' });
|
||||
reg.scheduleSync(0);
|
||||
} catch (error) {
|
||||
alert(error.message);
|
||||
|
||||
@@ -67,7 +67,7 @@ class SideMenuContentComponent extends Component {
|
||||
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Notes',
|
||||
folderId: folder.id,
|
||||
});
|
||||
@@ -78,7 +78,7 @@ class SideMenuContentComponent extends Component {
|
||||
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
type: 'NAV_GO',
|
||||
routeName: 'OneDriveLogin',
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user