Handle settings live refresh, unsubscribe subscriptions

This commit is contained in:
Michael Shamoon
2022-09-30 15:39:02 -07:00
parent e36b79444f
commit 4ec77788f1
2 changed files with 107 additions and 74 deletions

View File

@@ -1,6 +1,7 @@
import { DOCUMENT } from '@angular/common'
import { HttpClient } from '@angular/common/http'
import {
EventEmitter,
Inject,
Injectable,
LOCALE_ID,
@@ -46,6 +47,8 @@ export class SettingsService {
public displayName: string
public settingsSaved: EventEmitter<any> = new EventEmitter()
constructor(
rendererFactory: RendererFactory2,
@Inject(DOCUMENT) private document,
@@ -370,7 +373,13 @@ export class SettingsService {
}
storeSettings(): Observable<any> {
return this.http.post(this.baseUrl, { settings: this.settings })
return this.http.post(this.baseUrl, { settings: this.settings }).pipe(
tap((results) => {
if (results.success) {
this.settingsSaved.emit()
}
})
)
}
maybeMigrateSettings() {