aboutsummaryrefslogtreecommitdiff
path: root/src/background/repositories
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/repositories')
-rw-r--r--src/background/repositories/CachedSettingRepository.ts (renamed from src/background/repositories/SettingRepository.ts)2
-rw-r--r--src/background/repositories/LocalSettingRepository.ts (renamed from src/background/repositories/PersistentSettingRepository.ts)13
2 files changed, 13 insertions, 2 deletions
diff --git a/src/background/repositories/SettingRepository.ts b/src/background/repositories/CachedSettingRepository.ts
index ba24e36..b73d94a 100644
--- a/src/background/repositories/SettingRepository.ts
+++ b/src/background/repositories/CachedSettingRepository.ts
@@ -6,7 +6,7 @@ import Properties from '../../shared/settings/Properties';
const CACHED_SETTING_KEY = 'setting';
@injectable()
-export default class SettingRepository {
+export default class CachedSettingRepository {
private cache: MemoryStorage;
constructor() {
diff --git a/src/background/repositories/PersistentSettingRepository.ts b/src/background/repositories/LocalSettingRepository.ts
index c10f2cf..285b207 100644
--- a/src/background/repositories/PersistentSettingRepository.ts
+++ b/src/background/repositories/LocalSettingRepository.ts
@@ -2,7 +2,7 @@ import { injectable } from 'tsyringe';
import SettingData from '../../shared/SettingData';
@injectable()
-export default class SettingRepository {
+export default class LocalSettingRepository {
async load(): Promise<SettingData | null> {
const { settings } = await browser.storage.local.get('settings');
if (!settings) {
@@ -10,5 +10,16 @@ export default class SettingRepository {
}
return SettingData.fromJSON(settings as any);
}
+
+ onChange(callback: () => void) {
+ browser.storage.onChanged.addListener((changes, area) => {
+ if (area !== 'local') {
+ return;
+ }
+ if (changes.settings) {
+ callback();
+ }
+ });
+ }
}