mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
fix: prevent multiple heavy setting inits
This commit is contained in:
committed by
Rainer Killinger
parent
15ccbe4c18
commit
f7726378f4
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user