1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Background sync support

This commit is contained in:
Laurent Cozic
2017-07-22 18:35:39 +01:00
parent 7c60e32e64
commit 4f7edf8371
2 changed files with 60 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ import { DatabaseDriverReactNative } from 'lib/database-driver-react-native';
import { reg } from 'lib/registry.js';
import { _, setLocale } from 'lib/locale.js';
import RNFetchBlob from 'react-native-fetch-blob';
import { PoorManIntervals } from 'lib/poor-man-intervals.js';
let defaultState = {
notes: [],
@@ -303,6 +304,10 @@ const reducer = (state = defaultState, action) => {
throw error;
}
// Check the registered intervals here since we know this function
// will be called regularly.
PoorManIntervals.update();
return newState;
}
@@ -410,6 +415,11 @@ async function initialize(dispatch, backButtonHandler) {
return backButtonHandler();
});
PoorManIntervals.setInterval(() => {
reg.logger().info('Running background sync on timer...');
reg.scheduleSync(1);
}, 1000 * 60 * 5);
initializationState_ = 'done';
reg.logger().info('Application initialized');