You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Tools: Apply rule @typescript-eslint/type-annotation-spacing
This commit is contained in:
@@ -18,7 +18,7 @@ export default class Alarm extends BaseModel {
|
||||
return BaseModel.TYPE_ALARM;
|
||||
}
|
||||
|
||||
static byNoteId(noteId:string) {
|
||||
static byNoteId(noteId: string) {
|
||||
return this.modelSelectOne('SELECT * FROM alarms WHERE note_id = ?', [noteId]);
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ export default class Alarm extends BaseModel {
|
||||
static async alarmIdsWithoutNotes() {
|
||||
// https://stackoverflow.com/a/4967229/561309
|
||||
const alarms = await this.db().selectAll('SELECT alarms.id FROM alarms LEFT JOIN notes ON alarms.note_id = notes.id WHERE notes.id IS NULL');
|
||||
return alarms.map((a:any) => {
|
||||
return alarms.map((a: any) => {
|
||||
return a.id;
|
||||
});
|
||||
}
|
||||
|
||||
static async makeNotification(alarm:any, note:any = null):Promise<Notification> {
|
||||
static async makeNotification(alarm: any, note: any = null): Promise<Notification> {
|
||||
if (!note) {
|
||||
note = await Note.load(alarm.note_id);
|
||||
} else if (!note.todo_due) {
|
||||
@@ -43,7 +43,7 @@ export default class Alarm extends BaseModel {
|
||||
this.logger().warn('Reloaded note:', note);
|
||||
}
|
||||
|
||||
const output:Notification = {
|
||||
const output: Notification = {
|
||||
id: alarm.id,
|
||||
noteId: alarm.note_id,
|
||||
date: new Date(note.todo_due),
|
||||
|
||||
@@ -14,12 +14,12 @@ export default class NoteResource extends BaseModel {
|
||||
return BaseModel.TYPE_NOTE_RESOURCE;
|
||||
}
|
||||
|
||||
static async associatedNoteIds(resourceId:string):Promise<string[]> {
|
||||
static async associatedNoteIds(resourceId: string): Promise<string[]> {
|
||||
const rows = await this.modelSelectAll('SELECT note_id FROM note_resources WHERE resource_id = ? AND is_associated = 1', [resourceId]);
|
||||
return rows.map((r:any) => r.note_id);
|
||||
return rows.map((r: any) => r.note_id);
|
||||
}
|
||||
|
||||
static async setAssociatedResources(noteId:string, resourceIds:string[]) {
|
||||
static async setAssociatedResources(noteId: string, resourceIds: string[]) {
|
||||
const existingRows = await this.modelSelectAll('SELECT * FROM note_resources WHERE note_id = ?', [noteId]);
|
||||
|
||||
const notProcessedResourceIds = resourceIds.slice();
|
||||
@@ -53,11 +53,11 @@ export default class NoteResource extends BaseModel {
|
||||
await this.db().transactionExecBatch(queries);
|
||||
}
|
||||
|
||||
static async remove(noteId:string) {
|
||||
static async remove(noteId: string) {
|
||||
await this.db().exec({ sql: 'UPDATE note_resources SET is_associated = 0 WHERE note_id = ?', params: [noteId] });
|
||||
}
|
||||
|
||||
static async orphanResources(expiryDelay:number = null) {
|
||||
static async orphanResources(expiryDelay: number = null) {
|
||||
if (expiryDelay === null) expiryDelay = 1000 * 60 * 60 * 24 * 10;
|
||||
const cutOffTime = Date.now() - expiryDelay;
|
||||
const output = await this.modelSelectAll(
|
||||
@@ -71,10 +71,10 @@ export default class NoteResource extends BaseModel {
|
||||
`,
|
||||
[cutOffTime]
|
||||
);
|
||||
return output.map((r:any) => r.resource_id);
|
||||
return output.map((r: any) => r.resource_id);
|
||||
}
|
||||
|
||||
static async deleteByResource(resourceId:string) {
|
||||
static async deleteByResource(resourceId: string) {
|
||||
await this.db().exec('DELETE FROM note_resources WHERE resource_id = ?', [resourceId]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,23 +32,23 @@ export interface SettingItem {
|
||||
key?: string,
|
||||
isEnum?: boolean,
|
||||
section?: string,
|
||||
label?():string,
|
||||
description?(appType:string):string,
|
||||
options?():any,
|
||||
appTypes?:string[],
|
||||
show?(settings:any):boolean,
|
||||
filter?(value:any):any,
|
||||
label?(): string,
|
||||
description?(appType: string): string,
|
||||
options?(): any,
|
||||
appTypes?: string[],
|
||||
show?(settings: any): boolean,
|
||||
filter?(value: any): any,
|
||||
secure?: boolean,
|
||||
advanced?: boolean,
|
||||
minimum?: number,
|
||||
maximum?: number,
|
||||
step?: number,
|
||||
onClick?():void,
|
||||
unitLabel?(value:any):string,
|
||||
onClick?(): void,
|
||||
unitLabel?(value: any): string,
|
||||
}
|
||||
|
||||
interface SettingItems {
|
||||
[key:string]: SettingItem,
|
||||
[key: string]: SettingItem,
|
||||
}
|
||||
|
||||
// This is where the actual setting values are stored.
|
||||
@@ -66,18 +66,18 @@ export interface SettingSection {
|
||||
}
|
||||
|
||||
interface SettingSections {
|
||||
[key:string]: SettingSection,
|
||||
[key: string]: SettingSection,
|
||||
}
|
||||
|
||||
class Setting extends BaseModel {
|
||||
|
||||
private static metadata_:SettingItems = null;
|
||||
private static keychainService_:any = null;
|
||||
private static keys_:string[] = null;
|
||||
private static cache_:CacheItem[] = [];
|
||||
private static saveTimeoutId_:any = null;
|
||||
private static customMetadata_:SettingItems = {};
|
||||
private static customSections_:SettingSections = {};
|
||||
private static metadata_: SettingItems = null;
|
||||
private static keychainService_: any = null;
|
||||
private static keys_: string[] = null;
|
||||
private static cache_: CacheItem[] = [];
|
||||
private static saveTimeoutId_: any = null;
|
||||
private static customMetadata_: SettingItems = {};
|
||||
private static customSections_: SettingSections = {};
|
||||
|
||||
static tableName() {
|
||||
return 'settings';
|
||||
@@ -102,11 +102,11 @@ class Setting extends BaseModel {
|
||||
return this.keychainService_;
|
||||
}
|
||||
|
||||
static setKeychainService(s:any) {
|
||||
static setKeychainService(s: any) {
|
||||
this.keychainService_ = s;
|
||||
}
|
||||
|
||||
static metadata():SettingItems {
|
||||
static metadata(): SettingItems {
|
||||
if (this.metadata_) return this.metadata_;
|
||||
|
||||
const platform = shim.platformName();
|
||||
@@ -126,7 +126,7 @@ class Setting extends BaseModel {
|
||||
// public for the mobile and desktop apps because they are handled separately in menus.
|
||||
|
||||
const themeOptions = () => {
|
||||
const output:any = {};
|
||||
const output: any = {};
|
||||
output[Setting.THEME_LIGHT] = _('Light');
|
||||
output[Setting.THEME_DARK] = _('Dark');
|
||||
output[Setting.THEME_DRACULA] = _('Dracula');
|
||||
@@ -157,7 +157,7 @@ class Setting extends BaseModel {
|
||||
public: true,
|
||||
section: 'sync',
|
||||
label: () => _('Synchronisation target'),
|
||||
description: (appType:string) => {
|
||||
description: (appType: string) => {
|
||||
return appType !== 'cli' ? null : _('The target to synchonise to. Each sync target may have additional parameters which are named as `sync.NUM.NAME` (all documented below).');
|
||||
},
|
||||
options: () => {
|
||||
@@ -175,14 +175,14 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
try {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('filesystem');
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
filter: (value:any) => {
|
||||
filter: (value: any) => {
|
||||
return value ? rtrimSlashes(value) : '';
|
||||
},
|
||||
public: true,
|
||||
@@ -194,7 +194,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('nextcloud');
|
||||
},
|
||||
public: true,
|
||||
@@ -205,7 +205,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('nextcloud');
|
||||
},
|
||||
public: true,
|
||||
@@ -215,7 +215,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('nextcloud');
|
||||
},
|
||||
public: true,
|
||||
@@ -227,7 +227,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('webdav');
|
||||
},
|
||||
public: true,
|
||||
@@ -238,7 +238,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('webdav');
|
||||
},
|
||||
public: true,
|
||||
@@ -248,7 +248,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('webdav');
|
||||
},
|
||||
public: true,
|
||||
@@ -260,7 +260,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
try {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('amazon_s3');
|
||||
} catch (error) {
|
||||
@@ -278,7 +278,7 @@ class Setting extends BaseModel {
|
||||
value: 'https://s3.amazonaws.com/',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('amazon_s3');
|
||||
},
|
||||
public: true,
|
||||
@@ -289,7 +289,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('amazon_s3');
|
||||
},
|
||||
public: true,
|
||||
@@ -299,7 +299,7 @@ class Setting extends BaseModel {
|
||||
value: '',
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return settings['sync.target'] == SyncTargetRegistry.nameToId('amazon_s3');
|
||||
},
|
||||
public: true,
|
||||
@@ -366,7 +366,7 @@ class Setting extends BaseModel {
|
||||
public: true,
|
||||
label: () => _('Date format'),
|
||||
options: () => {
|
||||
const options:any = {};
|
||||
const options: any = {};
|
||||
const now = new Date('2017-01-30T12:00:00').getTime();
|
||||
options[Setting.DATE_FORMAT_1] = time.formatMsToLocal(now, Setting.DATE_FORMAT_1);
|
||||
options[Setting.DATE_FORMAT_2] = time.formatMsToLocal(now, Setting.DATE_FORMAT_2);
|
||||
@@ -385,7 +385,7 @@ class Setting extends BaseModel {
|
||||
public: true,
|
||||
label: () => _('Time format'),
|
||||
options: () => {
|
||||
const options:any = {};
|
||||
const options: any = {};
|
||||
const now = new Date('2017-01-30T20:30:00').getTime();
|
||||
options[Setting.TIME_FORMAT_1] = time.formatMsToLocal(now, Setting.TIME_FORMAT_1);
|
||||
options[Setting.TIME_FORMAT_2] = time.formatMsToLocal(now, Setting.TIME_FORMAT_2);
|
||||
@@ -472,7 +472,7 @@ class Setting extends BaseModel {
|
||||
options: () => {
|
||||
const Note = require('./Note');
|
||||
const noteSortFields = ['user_updated_time', 'user_created_time', 'title', 'order'];
|
||||
const options:any = {};
|
||||
const options: any = {};
|
||||
for (let i = 0; i < noteSortFields.length; i++) {
|
||||
options[noteSortFields[i]] = toTitleCase(Note.fieldToLabel(noteSortFields[i]));
|
||||
}
|
||||
@@ -498,7 +498,7 @@ class Setting extends BaseModel {
|
||||
options: () => {
|
||||
const Folder = require('./Folder');
|
||||
const folderSortFields = ['title', 'last_note_user_updated_time'];
|
||||
const options:any = {};
|
||||
const options: any = {};
|
||||
for (let i = 0; i < folderSortFields.length; i++) {
|
||||
options[folderSortFields[i]] = toTitleCase(Folder.fieldToLabel(folderSortFields[i]));
|
||||
}
|
||||
@@ -759,7 +759,7 @@ class Setting extends BaseModel {
|
||||
advanced: true,
|
||||
label: () => _('Keyboard Mode'),
|
||||
options: () => {
|
||||
const output:any = {};
|
||||
const output: any = {};
|
||||
output[''] = _('Default');
|
||||
output['emacs'] = _('Emacs');
|
||||
output['vim'] = _('Vim');
|
||||
@@ -772,7 +772,7 @@ class Setting extends BaseModel {
|
||||
type: SettingItemType.String,
|
||||
section: 'sync',
|
||||
advanced: true,
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return [SyncTargetRegistry.nameToId('nextcloud'), SyncTargetRegistry.nameToId('webdav')].indexOf(settings['sync.target']) >= 0;
|
||||
},
|
||||
public: true,
|
||||
@@ -785,7 +785,7 @@ class Setting extends BaseModel {
|
||||
type: SettingItemType.Bool,
|
||||
advanced: true,
|
||||
section: 'sync',
|
||||
show: (settings:any) => {
|
||||
show: (settings: any) => {
|
||||
return [SyncTargetRegistry.nameToId('nextcloud'), SyncTargetRegistry.nameToId('webdav')].indexOf(settings['sync.target']) >= 0;
|
||||
},
|
||||
public: true,
|
||||
@@ -894,13 +894,13 @@ class Setting extends BaseModel {
|
||||
return this.metadata_;
|
||||
}
|
||||
|
||||
private static validateKey(key:string) {
|
||||
private static validateKey(key: string) {
|
||||
if (!key) throw new Error('Cannot register empty key');
|
||||
if (key.length > 128) throw new Error(`Key length cannot be longer than 128 characters: ${key}`);
|
||||
if (!key.match(/^[a-zA-Z0-9_\-.]+$/)) throw new Error(`Key must only contain characters /a-zA-Z0-9_-./ : ${key}`);
|
||||
}
|
||||
|
||||
static async registerSetting(key:string, metadataItem:SettingItem) {
|
||||
static async registerSetting(key: string, metadataItem: SettingItem) {
|
||||
this.validateKey(key);
|
||||
|
||||
this.customMetadata_[key] = metadataItem;
|
||||
@@ -925,11 +925,11 @@ class Setting extends BaseModel {
|
||||
});
|
||||
}
|
||||
|
||||
static async registerSection(name:string, section:SettingSection) {
|
||||
static async registerSection(name: string, section: SettingSection) {
|
||||
this.customSections_[name] = { ...section, name: name };
|
||||
}
|
||||
|
||||
static settingMetadata(key:string):SettingItem {
|
||||
static settingMetadata(key: string): SettingItem {
|
||||
const metadata = this.metadata();
|
||||
if (!(key in metadata)) throw new Error(`Unknown key: ${key}`);
|
||||
const output = Object.assign({}, metadata[key]);
|
||||
@@ -937,21 +937,21 @@ class Setting extends BaseModel {
|
||||
return output;
|
||||
}
|
||||
|
||||
static keyExists(key:string) {
|
||||
static keyExists(key: string) {
|
||||
return key in this.metadata();
|
||||
}
|
||||
|
||||
static keyDescription(key:string, appType:string = null) {
|
||||
static keyDescription(key: string, appType: string = null) {
|
||||
const md = this.settingMetadata(key);
|
||||
if (!md.description) return null;
|
||||
return md.description(appType);
|
||||
}
|
||||
|
||||
static isSecureKey(key:string) {
|
||||
static isSecureKey(key: string) {
|
||||
return this.metadata()[key] && this.metadata()[key].secure === true;
|
||||
}
|
||||
|
||||
static keys(publicOnly:boolean = false, appType:string = null, options:KeysOptions = null) {
|
||||
static keys(publicOnly: boolean = false, appType: string = null, options: KeysOptions = null) {
|
||||
options = Object.assign({}, {
|
||||
secureOnly: false,
|
||||
}, options);
|
||||
@@ -980,22 +980,22 @@ class Setting extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
static isPublic(key:string) {
|
||||
static isPublic(key: string) {
|
||||
return this.keys(true).indexOf(key) >= 0;
|
||||
}
|
||||
|
||||
// Low-level method to load a setting directly from the database. Should not be used in most cases.
|
||||
static loadOne(key:string) {
|
||||
static loadOne(key: string) {
|
||||
return this.modelSelectOne('SELECT * FROM settings WHERE key = ?', [key]);
|
||||
}
|
||||
|
||||
static load() {
|
||||
this.cancelScheduleSave();
|
||||
this.cache_ = [];
|
||||
return this.modelSelectAll('SELECT * FROM settings').then(async (rows:any[]) => {
|
||||
return this.modelSelectAll('SELECT * FROM settings').then(async (rows: any[]) => {
|
||||
this.cache_ = [];
|
||||
|
||||
const pushItemsToCache = (items:any[]) => {
|
||||
const pushItemsToCache = (items: any[]) => {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const c = items[i];
|
||||
|
||||
@@ -1013,7 +1013,7 @@ class Setting extends BaseModel {
|
||||
// saving to database shouldn't). When the keychain works, the secure keys
|
||||
// are deleted from the database and transfered to the keychain in saveAll().
|
||||
|
||||
const rowKeys = rows.map((r:any) => r.key);
|
||||
const rowKeys = rows.map((r: any) => r.key);
|
||||
const secureKeys = this.keys(false, null, { secureOnly: true });
|
||||
const secureItems = [];
|
||||
for (const key of secureKeys) {
|
||||
@@ -1037,7 +1037,7 @@ class Setting extends BaseModel {
|
||||
|
||||
static toPlainObject() {
|
||||
const keys = this.keys();
|
||||
const keyToValues:any = {};
|
||||
const keyToValues: any = {};
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
keyToValues[keys[i]] = this.value(keys[i]);
|
||||
}
|
||||
@@ -1051,12 +1051,12 @@ class Setting extends BaseModel {
|
||||
});
|
||||
}
|
||||
|
||||
static setConstant(key:string, value:any) {
|
||||
static setConstant(key: string, value: any) {
|
||||
if (!(key in this.constants_)) throw new Error(`Unknown constant key: ${key}`);
|
||||
this.constants_[key] = value;
|
||||
}
|
||||
|
||||
static setValue(key:string, value:any) {
|
||||
static setValue(key: string, value: any) {
|
||||
if (!this.cache_) throw new Error('Settings have not been initialized!');
|
||||
|
||||
value = this.formatValue(key, value);
|
||||
@@ -1108,28 +1108,28 @@ class Setting extends BaseModel {
|
||||
this.scheduleSave();
|
||||
}
|
||||
|
||||
static incValue(key:string, inc:any) {
|
||||
static incValue(key: string, inc: any) {
|
||||
return this.setValue(key, this.value(key) + inc);
|
||||
}
|
||||
|
||||
static toggle(key:string) {
|
||||
static toggle(key: string) {
|
||||
return this.setValue(key, !this.value(key));
|
||||
}
|
||||
|
||||
static objectValue(settingKey:string, objectKey:string, defaultValue:any = null) {
|
||||
static objectValue(settingKey: string, objectKey: string, defaultValue: any = null) {
|
||||
const o = this.value(settingKey);
|
||||
if (!o || !(objectKey in o)) return defaultValue;
|
||||
return o[objectKey];
|
||||
}
|
||||
|
||||
static setObjectValue(settingKey:string, objectKey:string, value:any) {
|
||||
static setObjectValue(settingKey: string, objectKey: string, value: any) {
|
||||
let o = this.value(settingKey);
|
||||
if (typeof o !== 'object') o = {};
|
||||
o[objectKey] = value;
|
||||
this.setValue(settingKey, o);
|
||||
}
|
||||
|
||||
static deleteObjectValue(settingKey:string, objectKey:string) {
|
||||
static deleteObjectValue(settingKey: string, objectKey: string) {
|
||||
const o = this.value(settingKey);
|
||||
if (typeof o !== 'object') return;
|
||||
delete o[objectKey];
|
||||
@@ -1143,7 +1143,7 @@ class Setting extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
static valueToString(key:string, value:any) {
|
||||
static valueToString(key: string, value: any) {
|
||||
const md = this.settingMetadata(key);
|
||||
value = this.formatValue(key, value);
|
||||
if (md.type == SettingItemType.Int) return value.toFixed(0);
|
||||
@@ -1155,12 +1155,12 @@ class Setting extends BaseModel {
|
||||
throw new Error(`Unhandled value type: ${md.type}`);
|
||||
}
|
||||
|
||||
static filterValue(key:string, value:any) {
|
||||
static filterValue(key: string, value: any) {
|
||||
const md = this.settingMetadata(key);
|
||||
return md.filter ? md.filter(value) : value;
|
||||
}
|
||||
|
||||
static formatValue(key:string, value:any) {
|
||||
static formatValue(key: string, value: any) {
|
||||
const md = this.settingMetadata(key);
|
||||
|
||||
if (md.type == SettingItemType.Int) return !value ? 0 : Math.floor(Number(value));
|
||||
@@ -1197,12 +1197,12 @@ class Setting extends BaseModel {
|
||||
throw new Error(`Unhandled value type: ${md.type}`);
|
||||
}
|
||||
|
||||
static value(key:string) {
|
||||
static value(key: string) {
|
||||
// Need to copy arrays and objects since in setValue(), the old value and new one is compared
|
||||
// with strict equality and the value is updated only if changed. However if the caller acquire
|
||||
// and object and change a key, the objects will be detected as equal. By returning a copy
|
||||
// we avoid this problem.
|
||||
function copyIfNeeded(value:any) {
|
||||
function copyIfNeeded(value: any) {
|
||||
if (value === null || value === undefined) return value;
|
||||
if (Array.isArray(value)) return value.slice();
|
||||
if (typeof value === 'object') return Object.assign({}, value);
|
||||
@@ -1228,12 +1228,12 @@ class Setting extends BaseModel {
|
||||
return copyIfNeeded(md.value);
|
||||
}
|
||||
|
||||
static isEnum(key:string) {
|
||||
static isEnum(key: string) {
|
||||
const md = this.settingMetadata(key);
|
||||
return md.isEnum === true;
|
||||
}
|
||||
|
||||
static enumOptionValues(key:string) {
|
||||
static enumOptionValues(key: string) {
|
||||
const options = this.enumOptions(key);
|
||||
const output = [];
|
||||
for (const n in options) {
|
||||
@@ -1243,7 +1243,7 @@ class Setting extends BaseModel {
|
||||
return output;
|
||||
}
|
||||
|
||||
static enumOptionLabel(key:string, value:any) {
|
||||
static enumOptionLabel(key: string, value: any) {
|
||||
const options = this.enumOptions(key);
|
||||
for (const n in options) {
|
||||
if (n == value) return options[n];
|
||||
@@ -1251,14 +1251,14 @@ class Setting extends BaseModel {
|
||||
return '';
|
||||
}
|
||||
|
||||
static enumOptions(key:string) {
|
||||
static enumOptions(key: string) {
|
||||
const metadata = this.metadata();
|
||||
if (!metadata[key]) throw new Error(`Unknown key: ${key}`);
|
||||
if (!metadata[key].options) throw new Error(`No options for: ${key}`);
|
||||
return metadata[key].options();
|
||||
}
|
||||
|
||||
static enumOptionsDoc(key:string, templateString:string = null) {
|
||||
static enumOptionsDoc(key: string, templateString: string = null) {
|
||||
if (templateString === null) templateString = '%s: %s';
|
||||
const options = this.enumOptions(key);
|
||||
const output = [];
|
||||
@@ -1269,7 +1269,7 @@ class Setting extends BaseModel {
|
||||
return output.join(', ');
|
||||
}
|
||||
|
||||
static isAllowedEnumOption(key:string, value:any) {
|
||||
static isAllowedEnumOption(key: string, value: any) {
|
||||
const options = this.enumOptions(key);
|
||||
return !!options[value];
|
||||
}
|
||||
@@ -1278,10 +1278,10 @@ class Setting extends BaseModel {
|
||||
// { sync.5.path: 'http://example', sync.5.username: 'testing' }
|
||||
// and baseKey is 'sync.5', the function will return
|
||||
// { path: 'http://example', username: 'testing' }
|
||||
static subValues(baseKey:string, settings:any, options:any = null) {
|
||||
static subValues(baseKey: string, settings: any, options: any = null) {
|
||||
const includeBaseKeyInName = !!options && !!options.includeBaseKeyInName;
|
||||
|
||||
const output:any = {};
|
||||
const output: any = {};
|
||||
for (const key in settings) {
|
||||
if (!settings.hasOwnProperty(key)) continue;
|
||||
if (key.indexOf(baseKey) === 0) {
|
||||
@@ -1364,12 +1364,12 @@ class Setting extends BaseModel {
|
||||
this.saveTimeoutId_ = null;
|
||||
}
|
||||
|
||||
static publicSettings(appType:string) {
|
||||
static publicSettings(appType: string) {
|
||||
if (!appType) throw new Error('appType is required');
|
||||
|
||||
const metadata = this.metadata();
|
||||
|
||||
const output:any = {};
|
||||
const output: any = {};
|
||||
for (const key in metadata) {
|
||||
if (!metadata.hasOwnProperty(key)) continue;
|
||||
const s = Object.assign({}, metadata[key]);
|
||||
@@ -1381,7 +1381,7 @@ class Setting extends BaseModel {
|
||||
return output;
|
||||
}
|
||||
|
||||
static typeToString(typeId:number) {
|
||||
static typeToString(typeId: number) {
|
||||
if (typeId === SettingItemType.Int) return 'int';
|
||||
if (typeId === SettingItemType.String) return 'string';
|
||||
if (typeId === SettingItemType.Bool) return 'bool';
|
||||
@@ -1390,10 +1390,10 @@ class Setting extends BaseModel {
|
||||
throw new Error(`Invalid type ID: ${typeId}`);
|
||||
}
|
||||
|
||||
static groupMetadatasBySections(metadatas:SettingItem[]) {
|
||||
static groupMetadatasBySections(metadatas: SettingItem[]) {
|
||||
const sections = [];
|
||||
const generalSection:any = { name: 'general', metadatas: [] };
|
||||
const nameToSections:any = {};
|
||||
const generalSection: any = { name: 'general', metadatas: [] };
|
||||
const nameToSections: any = {};
|
||||
nameToSections['general'] = generalSection;
|
||||
sections.push(generalSection);
|
||||
for (let i = 0; i < metadatas.length; i++) {
|
||||
@@ -1419,7 +1419,7 @@ class Setting extends BaseModel {
|
||||
return sections;
|
||||
}
|
||||
|
||||
static sectionNameToLabel(name:string) {
|
||||
static sectionNameToLabel(name: string) {
|
||||
if (name === 'general') return _('General');
|
||||
if (name === 'sync') return _('Synchronisation');
|
||||
if (name === 'appearance') return _('Appearance');
|
||||
@@ -1437,7 +1437,7 @@ class Setting extends BaseModel {
|
||||
return name;
|
||||
}
|
||||
|
||||
static sectionDescription(name:string) {
|
||||
static sectionDescription(name: string) {
|
||||
if (name === 'markdownPlugins') return _('These plugins enhance the Markdown renderer with additional features. Please note that, while these features might be useful, they are not standard Markdown and thus most of them will only work in Joplin. Additionally, some of them are *incompatible* with the WYSIWYG editor. If you open a note that uses one of these plugins in that editor, you will lose the plugin formatting. It is indicated below which plugins are compatible or not with the WYSIWYG editor.');
|
||||
if (name === 'general') return _('Notes and settings are stored in: %s', toSystemSlashes(this.value('profileDir'), process.platform));
|
||||
|
||||
@@ -1446,7 +1446,7 @@ class Setting extends BaseModel {
|
||||
return '';
|
||||
}
|
||||
|
||||
static sectionNameToIcon(name:string) {
|
||||
static sectionNameToIcon(name: string) {
|
||||
if (name === 'general') return 'icon-general';
|
||||
if (name === 'sync') return 'icon-sync';
|
||||
if (name === 'appearance') return 'icon-appearance';
|
||||
@@ -1464,7 +1464,7 @@ class Setting extends BaseModel {
|
||||
return name;
|
||||
}
|
||||
|
||||
static appTypeToLabel(name:string) {
|
||||
static appTypeToLabel(name: string) {
|
||||
// Not translated for now because only used on Welcome notes (which are not translated)
|
||||
if (name === 'cli') return 'CLI';
|
||||
return name[0].toUpperCase() + name.substr(1).toLowerCase();
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface WhereQuery {
|
||||
|
||||
// Note: this method might return more fields than was requested as it will
|
||||
// also return fields that are necessary for pagination.
|
||||
export default async function(db:any, tableName:string, pagination:Pagination, whereQuery:WhereQuery = null, fields:string[] = null):Promise<ModelFeedPage> {
|
||||
export default async function(db: any, tableName: string, pagination: Pagination, whereQuery: WhereQuery = null, fields: string[] = null): Promise<ModelFeedPage> {
|
||||
fields = fields ? fields.slice() : ['id'];
|
||||
|
||||
const where = whereQuery ? [whereQuery.sql] : [];
|
||||
@@ -25,7 +25,7 @@ export default async function(db:any, tableName:string, pagination:Pagination, w
|
||||
|
||||
const paginationOrder = pagination.order[0].dir;
|
||||
|
||||
if (!pagination.order.find((o:PaginationOrder) => o.by === 'id')) {
|
||||
if (!pagination.order.find((o: PaginationOrder) => o.by === 'id')) {
|
||||
pagination = {
|
||||
...pagination,
|
||||
order: pagination.order.concat([{
|
||||
@@ -52,7 +52,7 @@ export default async function(db:any, tableName:string, pagination:Pagination, w
|
||||
|
||||
const rows = await db.selectAll(sql, sqlParams);
|
||||
|
||||
const output:ModelFeedPage = { items: rows };
|
||||
const output: ModelFeedPage = { items: rows };
|
||||
|
||||
if (rows.length >= pagination.limit) output.has_more = true;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Pagination } from './types';
|
||||
|
||||
export default function(pagination:Pagination):string {
|
||||
const sql:string[] = [];
|
||||
export default function(pagination: Pagination): string {
|
||||
const sql: string[] = [];
|
||||
|
||||
for (let i = 0; i < pagination.order.length; i++) {
|
||||
const o = pagination.order[i];
|
||||
|
||||
Reference in New Issue
Block a user