Browse Source

smarter sync polling

pull/12/head
Kyle Spearrin 9 years ago
parent
commit
214ec930c3
  1. 16
      src/background.js

16
src/background.js

@ -253,9 +253,17 @@ function copyToClipboard(text) { @@ -253,9 +253,17 @@ function copyToClipboard(text) {
}
}
fullSync();
setInterval(fullSync, 6 * 60 * 1000);
// Sync polling
function fullSync() {
syncService.fullSync(function() {});
fullSync(true);
setInterval(fullSync, 5 * 60 * 1000); // check every 5 minutes
var syncInternal = 6 * 60 * 60 * 1000; // 6 hours
function fullSync(override) {
syncService.getLastSync(function (lastSync) {
var now = new Date();
if (override || !lastSync || (now - lastSync) >= syncInternal) {
syncService.fullSync(function () { });
}
});
}

Loading…
Cancel
Save