Make Properties class
This commit is contained in:
parent
2116ac90a6
commit
574692551a
16 changed files with 179 additions and 236 deletions
|
@ -1,7 +1,7 @@
|
|||
import { injectable } from 'tsyringe';
|
||||
import MemoryStorage from '../infrastructures/MemoryStorage';
|
||||
import Settings, { valueOf, toJSON } from '../../shared/Settings';
|
||||
import * as PropertyDefs from '../../shared/property-defs';
|
||||
import Properties from '../../shared/settings/Properties';
|
||||
|
||||
const CACHED_SETTING_KEY = 'setting';
|
||||
|
||||
|
@ -26,7 +26,7 @@ export default class SettingRepository {
|
|||
async setProperty(
|
||||
name: string, value: string | number | boolean,
|
||||
): Promise<void> {
|
||||
let def = PropertyDefs.defs.find(d => name === d.name);
|
||||
let def = Properties.def(name);
|
||||
if (!def) {
|
||||
throw new Error('unknown property: ' + name);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import CompletionsRepository from '../repositories/CompletionsRepository';
|
|||
import * as filters from './filters';
|
||||
import SettingRepository from '../repositories/SettingRepository';
|
||||
import TabPresenter from '../presenters/TabPresenter';
|
||||
import * as PropertyDefs from '../../shared/property-defs';
|
||||
import Properties from '../../shared/settings/Properties';
|
||||
|
||||
const COMPLETION_ITEM_LIMIT = 10;
|
||||
|
||||
|
@ -129,7 +129,7 @@ export default class CompletionsUseCase {
|
|||
}
|
||||
|
||||
querySet(name: string, keywords: string): Promise<CompletionGroup[]> {
|
||||
let items = PropertyDefs.defs.map((def) => {
|
||||
let items = Properties.defs().map((def) => {
|
||||
if (def.type === 'boolean') {
|
||||
return [
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as PropertyDefs from '../../shared//property-defs';
|
||||
import Properties from '../../shared/settings/Properties';
|
||||
|
||||
const mustNumber = (v: any): number => {
|
||||
let num = Number(v);
|
||||
|
@ -16,7 +16,7 @@ const parseSetOption = (
|
|||
value = !key.startsWith('no');
|
||||
key = value ? key : key.slice(2);
|
||||
}
|
||||
let def = PropertyDefs.defs.find(d => d.name === key);
|
||||
let def = Properties.def(key);
|
||||
if (!def) {
|
||||
throw new Error('Unknown property: ' + key);
|
||||
}
|
||||
|
|
Reference in a new issue