mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-12 11:15:22 +02:00
improving settings fetching
This commit is contained in:
parent
b6b8a9e203
commit
8029793ffb
@ -9,6 +9,7 @@ import {IPrivateConfig, ServerConfig} from '../../../../common/config/private/IP
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class SettingsService {
|
export class SettingsService {
|
||||||
public settings: BehaviorSubject<IPrivateConfig>;
|
public settings: BehaviorSubject<IPrivateConfig>;
|
||||||
|
private fetchingSettings = false;
|
||||||
|
|
||||||
constructor(private _networkService: NetworkService) {
|
constructor(private _networkService: NetworkService) {
|
||||||
this.settings = new BehaviorSubject<IPrivateConfig>({
|
this.settings = new BehaviorSubject<IPrivateConfig>({
|
||||||
@ -127,7 +128,16 @@ export class SettingsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getSettings(): Promise<void> {
|
public async getSettings(): Promise<void> {
|
||||||
this.settings.next(await this._networkService.getJson<Promise<IPrivateConfig>>('/settings'));
|
if (this.fetchingSettings === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.fetchingSettings = true;
|
||||||
|
try {
|
||||||
|
this.settings.next(await this._networkService.getJson<Promise<IPrivateConfig>>('/settings'));
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
this.fetchingSettings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user