aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases/SettingUseCase.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/usecases/SettingUseCase.js')
-rw-r--r--src/background/usecases/SettingUseCase.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/background/usecases/SettingUseCase.js b/src/background/usecases/SettingUseCase.js
new file mode 100644
index 0000000..fe3ca5d
--- /dev/null
+++ b/src/background/usecases/SettingUseCase.js
@@ -0,0 +1,32 @@
+import Setting from '../domains/Setting';
+// eslint-disable-next-line max-len
+import PersistentSettingRepository from '../repositories/PersistentSettingRepository';
+import SettingRepository from '../repositories/SettingRepository';
+
+export default class SettingUseCase {
+ constructor() {
+ this.persistentSettingRepository = new PersistentSettingRepository();
+ this.settingRepository = new SettingRepository();
+ }
+
+ save(settings) {
+ this.persistentSettingRepository.save(settings);
+ }
+
+ get() {
+ return this.settingRepository.get();
+ }
+
+ async reload() {
+ let settings = await this.persistentSettingRepository.load();
+ if (!settings) {
+ settings = Setting.defaultSettings();
+ }
+
+ let value = settings.value();
+
+ this.settingRepository.update(value);
+
+ return value;
+ }
+}