mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 17:36:15 -08:00
fix(settings): settings store initialization
This commit is contained in:
1 parent
b565636189
commit
b70d87faf2
3 files changed
+14
-20
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import { computed, inject } from '@angular/core';
|
||||
import { inject } from '@angular/core';
|
||||
import {
|
||||
patchState,
|
||||
signalStore,
|
||||
withComputed,
|
||||
withHooks,
|
||||
withMethods,
|
||||
withState,
|
||||
} from '@ngrx/signals';
|
||||
@@ -28,11 +28,6 @@ const DEFAULT_SETTINGS: Settings = {
|
||||
export const SettingsStore = signalStore(
|
||||
{ providedIn: 'root' },
|
||||
withState<Settings>(DEFAULT_SETTINGS),
|
||||
withComputed((store) => ({
|
||||
player: computed(() => store.player()),
|
||||
showCaptions: computed(() => store.showCaptions()),
|
||||
theme: computed(() => store.theme()),
|
||||
})),
|
||||
withMethods((store, storage = inject(StorageMap)) => ({
|
||||
async loadSettings() {
|
||||
const stored = await firstValueFrom(
|
||||
@@ -64,5 +59,10 @@ export const SettingsStore = signalStore(
|
||||
epgUrl: store.epgUrl(),
|
||||
};
|
||||
},
|
||||
}))
|
||||
})),
|
||||
withHooks({
|
||||
onInit(store) {
|
||||
store.loadSettings();
|
||||
},
|
||||
})
|
||||
);
|
||||
@@ -178,8 +178,7 @@ export class SettingsComponent implements OnInit {
|
||||
/**
|
||||
* Sets saved settings from the indexed db store
|
||||
*/
|
||||
async setSettings() {
|
||||
await this.settingsStore.loadSettings();
|
||||
setSettings() {
|
||||
const currentSettings = this.settingsStore.getSettings();
|
||||
this.settingsForm.patchValue(currentSettings);
|
||||
|
||||
|
||||
@@ -167,15 +167,10 @@ export class NavigationBarComponent implements OnChanges {
|
||||
}
|
||||
|
||||
openSettings(): void {
|
||||
this.dialog
|
||||
.open(SettingsComponent, {
|
||||
width: '1000px',
|
||||
height: '90%',
|
||||
data: { isDialog: true },
|
||||
})
|
||||
.afterClosed()
|
||||
.subscribe(() => {
|
||||
this.settingsStore.loadSettings();
|
||||
});
|
||||
this.dialog.open(SettingsComponent, {
|
||||
width: '1000px',
|
||||
height: '90%',
|
||||
data: { isDialog: true },
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user