mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
All: Fixed sync interval sorting order
This commit is contained in:
parent
e1fd9c6922
commit
14a93a9f26
@ -40,10 +40,6 @@ class ConfigScreenComponent extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
output.sort((a, b) => {
|
||||
return a.label.toLowerCase() < b.label.toLowerCase() ? -1 : +1;
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
31
ReactNativeClient/lib/ObjectUtils.js
Normal file
31
ReactNativeClient/lib/ObjectUtils.js
Normal file
@ -0,0 +1,31 @@
|
||||
const ObjectUtils = {};
|
||||
|
||||
ObjectUtils.sortByValue = function(object) {
|
||||
const temp = [];
|
||||
for (let k in object) {
|
||||
if (!object.hasOwnProperty(k)) continue;
|
||||
temp.push({
|
||||
key: k,
|
||||
value: object[k],
|
||||
});
|
||||
}
|
||||
|
||||
temp.sort(function(a, b) {
|
||||
let v1 = a.value;
|
||||
let v2 = b.value;
|
||||
if (typeof v1 === 'string') v1 = v1.toLowerCase();
|
||||
if (typeof v2 === 'string') v2 = v2.toLowerCase();
|
||||
if (v1 === v2) return 0;
|
||||
return v1 < v2 ? -1 : +1;
|
||||
});
|
||||
|
||||
const output = {};
|
||||
for (let i = 0; i < temp.length; i++) {
|
||||
const item = temp[i];
|
||||
output[item.key] = item.value;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
module.exports = ObjectUtils;
|
@ -4,6 +4,7 @@ const { Logger } = require('lib/logger.js');
|
||||
const SyncTargetRegistry = require('lib/SyncTargetRegistry.js');
|
||||
const { time } = require('lib/time-utils.js');
|
||||
const { sprintf } = require('sprintf-js');
|
||||
const ObjectUtils = require('lib/ObjectUtils');
|
||||
const { _, supportedLocalesToLanguages, defaultLocale } = require('lib/locale.js');
|
||||
|
||||
class Setting extends BaseModel {
|
||||
@ -24,7 +25,7 @@ class Setting extends BaseModel {
|
||||
'firstStart': { value: true, type: Setting.TYPE_BOOL, public: false },
|
||||
'editor': { value: '', type: Setting.TYPE_STRING, public: true, appTypes: ['cli'], label: () => _('Text editor'), description: () => _('The editor that will be used to open a note. If none is provided it will try to auto-detect the default editor.') },
|
||||
'locale': { value: defaultLocale(), type: Setting.TYPE_STRING, isEnum: true, public: true, label: () => _('Language'), options: () => {
|
||||
return supportedLocalesToLanguages();
|
||||
return ObjectUtils.sortByValue(supportedLocalesToLanguages());
|
||||
}},
|
||||
'dateFormat': { value: Setting.DATE_FORMAT_1, type: Setting.TYPE_STRING, isEnum: true, public: true, label: () => _('Date format'), options: () => {
|
||||
let options = {}
|
||||
|
@ -58,8 +58,8 @@ reg.scheduleSync = async (delay = null) => {
|
||||
|
||||
reg.logger().info('Scheduling sync operation...');
|
||||
|
||||
if (Setting.value('env') === 'dev') {
|
||||
reg.logger().info('Scheduling sync operation DISABLED!!!');
|
||||
if (Setting.value('env') === 'dev' && delay !== 0) {
|
||||
reg.logger().info('Schedule sync DISABLED!!!');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -147,6 +147,11 @@ reg.setupRecurrentSync = () => {
|
||||
} else {
|
||||
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!!!');
|
||||
return;
|
||||
}
|
||||
|
||||
reg.recurrentSyncId_ = shim.setInterval(() => {
|
||||
reg.logger().info('Running background sync on timer...');
|
||||
reg.scheduleSync(0);
|
||||
|
Loading…
Reference in New Issue
Block a user