aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
Diffstat (limited to 'src/background')
-rw-r--r--src/background/infrastructures/ContentMessageListener.ts5
-rw-r--r--src/background/repositories/SettingRepository.ts8
2 files changed, 8 insertions, 5 deletions
diff --git a/src/background/infrastructures/ContentMessageListener.ts b/src/background/infrastructures/ContentMessageListener.ts
index 3d24741..f348a74 100644
--- a/src/background/infrastructures/ContentMessageListener.ts
+++ b/src/background/infrastructures/ContentMessageListener.ts
@@ -8,6 +8,7 @@ import AddonEnabledController from '../controllers/AddonEnabledController';
import LinkController from '../controllers/LinkController';
import OperationController from '../controllers/OperationController';
import MarkController from '../controllers/MarkController';
+import { toJSON } from '../../shared/Settings';
@injectable()
export default class ContentMessageListener {
@@ -101,8 +102,8 @@ export default class ContentMessageListener {
return this.commandController.exec(text);
}
- onSettingsQuery(): Promise<any> {
- return this.settingController.getSetting();
+ async onSettingsQuery(): Promise<any> {
+ return toJSON(await this.settingController.getSetting());
}
onFindGetKeyword(): Promise<string> {
diff --git a/src/background/repositories/SettingRepository.ts b/src/background/repositories/SettingRepository.ts
index 2f159e5..c7a0e84 100644
--- a/src/background/repositories/SettingRepository.ts
+++ b/src/background/repositories/SettingRepository.ts
@@ -1,6 +1,6 @@
import { injectable } from 'tsyringe';
import MemoryStorage from '../infrastructures/MemoryStorage';
-import Settings from '../../shared/Settings';
+import Settings, { valueOf, toJSON } from '../../shared/Settings';
import * as PropertyDefs from '../../shared/property-defs';
const CACHED_SETTING_KEY = 'setting';
@@ -14,11 +14,13 @@ 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(valueOf(data));
}
update(value: Settings): void {
- return this.cache.set(CACHED_SETTING_KEY, value);
+ let data = toJSON(value);
+ return this.cache.set(CACHED_SETTING_KEY, data);
}
async setProperty(