diff options
Diffstat (limited to 'src/background/repositories')
| -rw-r--r-- | src/background/repositories/PersistentSettingRepository.ts | 2 | ||||
| -rw-r--r-- | src/background/repositories/SettingRepository.ts | 11 | 
2 files changed, 7 insertions, 6 deletions
diff --git a/src/background/repositories/PersistentSettingRepository.ts b/src/background/repositories/PersistentSettingRepository.ts index 927bce9..e3b78b3 100644 --- a/src/background/repositories/PersistentSettingRepository.ts +++ b/src/background/repositories/PersistentSettingRepository.ts @@ -8,7 +8,7 @@ export default class SettingRepository {      if (!settings) {        return null;      } -    return SettingData.valueOf(settings as any); +    return SettingData.fromJSON(settings as any);    }  } diff --git a/src/background/repositories/SettingRepository.ts b/src/background/repositories/SettingRepository.ts index 2f159e5..e775a32 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 from '../../shared/Settings'; -import * as PropertyDefs from '../../shared/property-defs'; +import Settings from '../../shared/settings/Settings'; +import Properties from '../../shared/settings/Properties';  const CACHED_SETTING_KEY = 'setting'; @@ -14,17 +14,18 @@ export default class SettingRepository {    }    get(): Promise<Settings> { -    return Promise.resolve(this.cache.get(CACHED_SETTING_KEY)); +    let data = this.cache.get(CACHED_SETTING_KEY); +    return Promise.resolve(Settings.fromJSON(data));    }    update(value: Settings): void { -    return this.cache.set(CACHED_SETTING_KEY, value); +    return this.cache.set(CACHED_SETTING_KEY, value.toJSON());    }    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);      }  | 
