fix: prevent multiple heavy setting inits

This commit is contained in:
Thea Schöbl
2022-11-04 10:49:12 +00:00
committed by Rainer Killinger
parent 15ccbe4c18
commit f7726378f4
7 changed files with 53 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019, 2020 StApps
* Copyright (C) 2022 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -96,6 +96,8 @@ export class SettingsProvider {
*/
private settingsActionSource = new Subject<SettingsAction>();
private needsInit = true;
/**
* Order of the setting categories
*/
@@ -332,6 +334,9 @@ export class SettingsProvider {
* Initializes settings from config and stored values if exist
*/
public async init(): Promise<void> {
if (!this.needsInit) return;
this.needsInit = false;
try {
const settings: SCSetting[] = this.configProvider.getValue(
'settings',
@@ -390,6 +395,7 @@ export class SettingsProvider {
*/
public async reset(): Promise<void> {
await this.storage.put(STORAGE_KEY_SETTING_VALUES, {});
this.needsInit = true;
await this.init();
}