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

Revert "Applied prettier to code base"

This reverts commit c4f19465a6.
This commit is contained in:
Laurent Cozic
2018-03-09 20:59:12 +00:00
parent 5e8b09f5af
commit 55c5ddedf4
203 changed files with 7883 additions and 13355 deletions

View File

@@ -1,8 +1,8 @@
const { Logger } = require("lib/logger.js");
const Setting = require("lib/models/Setting.js");
const { shim } = require("lib/shim.js");
const SyncTargetRegistry = require("lib/SyncTargetRegistry.js");
const { _ } = require("lib/locale.js");
const { Logger } = require('lib/logger.js');
const Setting = require('lib/models/Setting.js');
const { shim } = require('lib/shim.js');
const SyncTargetRegistry = require('lib/SyncTargetRegistry.js');
const { _ } = require('lib/locale.js');
const reg = {};
@@ -15,33 +15,33 @@ reg.logger = () => {
}
return reg.logger_;
};
}
reg.setLogger = l => {
reg.setLogger = (l) => {
reg.logger_ = l;
};
}
reg.setShowErrorMessageBoxHandler = v => {
reg.setShowErrorMessageBoxHandler = (v) => {
reg.showErrorMessageBoxHandler_ = v;
};
}
reg.showErrorMessageBox = message => {
reg.showErrorMessageBox = (message) => {
if (!reg.showErrorMessageBoxHandler_) return;
reg.showErrorMessageBoxHandler_(message);
};
}
reg.syncTarget = (syncTargetId = null) => {
if (syncTargetId === null) syncTargetId = Setting.value("sync.target");
if (syncTargetId === null) syncTargetId = Setting.value('sync.target');
if (reg.syncTargets_[syncTargetId]) return reg.syncTargets_[syncTargetId];
const SyncTargetClass = SyncTargetRegistry.classById(syncTargetId);
if (!reg.db()) throw new Error("Cannot initialize sync without a db");
if (!reg.db()) throw new Error('Cannot initialize sync without a db');
const target = new SyncTargetClass(reg.db());
target.setLogger(reg.logger());
reg.syncTargets_[syncTargetId] = target;
return target;
};
}
reg.scheduleSync = async (delay = null, syncOptions = null) => {
if (delay === null) delay = 1000 * 10;
@@ -57,7 +57,7 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
reg.scheduleSyncId_ = null;
}
reg.logger().info("Scheduling sync operation...");
reg.logger().info('Scheduling sync operation...');
// if (Setting.value("env") === "dev" && delay !== 0) {
// reg.logger().info("Schedule sync DISABLED!!!");
@@ -66,12 +66,12 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
const timeoutCallback = async () => {
reg.scheduleSyncId_ = null;
reg.logger().info("Preparing scheduled sync");
reg.logger().info('Preparing scheduled sync');
const syncTargetId = Setting.value("sync.target");
const syncTargetId = Setting.value('sync.target');
if (!reg.syncTarget(syncTargetId).isAuthenticated()) {
reg.logger().info("Synchroniser is missing credentials - manual sync required to authenticate.");
reg.logger().info('Synchroniser is missing credentials - manual sync required to authenticate.');
promiseResolve();
return;
}
@@ -79,7 +79,7 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
try {
const sync = await reg.syncTarget(syncTargetId).synchronizer();
const contextKey = "sync." + syncTargetId + ".context";
const contextKey = 'sync.' + syncTargetId + '.context';
let context = Setting.value(contextKey);
try {
context = context ? JSON.parse(context) : {};
@@ -87,8 +87,8 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
// Clearing the context is inefficient since it means all items are going to be re-downloaded
// however it won't result in duplicate items since the synchroniser is going to compare each
// item to the current state.
reg.logger().warn("Could not parse JSON sync context " + contextKey + ":", context);
reg.logger().info("Clearing context and starting from scratch");
reg.logger().warn('Could not parse JSON sync context ' + contextKey + ':', context);
reg.logger().info('Clearing context and starting from scratch');
context = null;
}
@@ -98,7 +98,7 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
const newContext = await sync.start(options);
Setting.setValue(contextKey, JSON.stringify(newContext));
} catch (error) {
if (error.code == "alreadyStarted") {
if (error.code == 'alreadyStarted') {
reg.logger().info(error.message);
} else {
promiseResolve();
@@ -106,7 +106,7 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
}
}
} catch (error) {
reg.logger().info("Could not run background sync:");
reg.logger().info('Could not run background sync:');
reg.logger().info(error);
// Special case to display OneDrive Business error. This is the full error that's received when trying to use a OneDrive Business account:
@@ -120,11 +120,7 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
// acfd6503-8d97-4349-ae2e-e7a19dd7b6bc\r\nTimestamp: 2017-12-01 13:35:55Z","error_codes":[50011],"timestamp":"2017-12-01 13:35:55Z","trace_id":
// "6e63dac6-8b37-47e2-bd1b-4768f8713400","correlation_id":"acfd6503-8d97-4349-ae2e-e7a19dd7b6bc"}
if (error && error.message && error.message.indexOf('"invalid_client"') >= 0) {
reg.showErrorMessageBox(
_(
"Could not synchronize with OneDrive.\n\nThis error often happens when using OneDrive for Business, which unfortunately cannot be supported.\n\nPlease consider using a regular OneDrive account."
)
);
reg.showErrorMessageBox(_('Could not synchronize with OneDrive.\n\nThis error often happens when using OneDrive for Business, which unfortunately cannot be supported.\n\nPlease consider using a regular OneDrive account.'));
}
}
@@ -140,7 +136,7 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
}
return promise;
};
}
reg.setupRecurrentSync = () => {
if (reg.recurrentSyncId_) {
@@ -148,29 +144,29 @@ reg.setupRecurrentSync = () => {
reg.recurrentSyncId_ = null;
}
if (!Setting.value("sync.interval")) {
reg.logger().debug("Recurrent sync is disabled");
if (!Setting.value('sync.interval')) {
reg.logger().debug('Recurrent sync is disabled');
} else {
reg.logger().debug("Setting up recurrent sync with interval " + Setting.value("sync.interval"));
reg.logger().debug('Setting up recurrent sync with interval ' + Setting.value('sync.interval'));
if (Setting.value("env") === "dev") {
reg.logger().info("Recurrent sync operation DISABLED!!!");
if (Setting.value('env') === 'dev') {
reg.logger().info('Recurrent sync operation DISABLED!!!');
return;
}
reg.recurrentSyncId_ = shim.setInterval(() => {
reg.logger().info("Running background sync on timer...");
reg.logger().info('Running background sync on timer...');
reg.scheduleSync(0);
}, 1000 * Setting.value("sync.interval"));
}, 1000 * Setting.value('sync.interval'));
}
};
}
reg.setDb = v => {
reg.setDb = (v) => {
reg.db_ = v;
};
}
reg.db = () => {
return reg.db_;
};
}
module.exports = { reg };
module.exports = { reg };