aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
authorShin'ya UEOKA <ueokande@i-beam.org>2019-10-05 02:06:02 +0000
committerShin'ya UEOKA <ueokande@i-beam.org>2019-10-06 12:58:59 +0000
commit574692551a27ea56660bf2061daeaa0d34beaff4 (patch)
tree414a7f1de8dfb24af45d7e392b72549bc67ad48a /src/background
parent2116ac90a6dfdb0910d7ad2896f70a052aa635cc (diff)
Make Properties class
Diffstat (limited to 'src/background')
-rw-r--r--src/background/repositories/SettingRepository.ts4
-rw-r--r--src/background/usecases/CompletionsUseCase.ts4
-rw-r--r--src/background/usecases/parsers.ts4
3 files changed, 6 insertions, 6 deletions
diff --git a/src/background/repositories/SettingRepository.ts b/src/background/repositories/SettingRepository.ts
index c7a0e84..a11b65f 100644
--- a/src/background/repositories/SettingRepository.ts
+++ b/src/background/repositories/SettingRepository.ts
@@ -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);
}
diff --git a/src/background/usecases/CompletionsUseCase.ts b/src/background/usecases/CompletionsUseCase.ts
index 8cd4f32..bfff1e6 100644
--- a/src/background/usecases/CompletionsUseCase.ts
+++ b/src/background/usecases/CompletionsUseCase.ts
@@ -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 [
{
diff --git a/src/background/usecases/parsers.ts b/src/background/usecases/parsers.ts
index 6135fd8..e8a1149 100644
--- a/src/background/usecases/parsers.ts
+++ b/src/background/usecases/parsers.ts
@@ -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);
}