mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 02:46:16 -08:00
fix: clear external player paths on save
Entire-Checkpoint: f957cd9849e0
This commit is contained in:
1 parent
2efdfea0c1
commit
4a21579aff
4 files changed
+111
-22
No files matched your search
@@ -925,4 +925,28 @@ describe('SettingsComponent', () => {
|
||||
component.settingsForm.value
|
||||
);
|
||||
});
|
||||
|
||||
it('clears external player paths in Electron when saved as empty', async () => {
|
||||
const mockStore = settingsStore as unknown as MockSettingsStore;
|
||||
mockStore.updateSettings.mockResolvedValue(undefined);
|
||||
const setMpvPlayerPath = jest.spyOn(
|
||||
window.electron,
|
||||
'setMpvPlayerPath'
|
||||
);
|
||||
const setVlcPlayerPath = jest.spyOn(
|
||||
window.electron,
|
||||
'setVlcPlayerPath'
|
||||
);
|
||||
|
||||
component.settingsForm.patchValue({
|
||||
mpvPlayerPath: '',
|
||||
vlcPlayerPath: '',
|
||||
});
|
||||
|
||||
component.onSubmit();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(setMpvPlayerPath).toHaveBeenCalledWith('');
|
||||
expect(setVlcPlayerPath).toHaveBeenCalledWith('');
|
||||
});
|
||||
});
|
||||
@@ -443,23 +443,22 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
* the indexed db store
|
||||
*/
|
||||
onSubmit(): void {
|
||||
this.settingsStore.updateSettings(this.settingsForm.value).then(() => {
|
||||
const settings = this.settingsForm.value;
|
||||
const mpvPlayerPath = this.normalizeExternalPlayerPath(
|
||||
settings.mpvPlayerPath
|
||||
);
|
||||
const vlcPlayerPath = this.normalizeExternalPlayerPath(
|
||||
settings.vlcPlayerPath
|
||||
);
|
||||
|
||||
this.settingsStore.updateSettings(settings).then(() => {
|
||||
this.applyChangedSettings();
|
||||
|
||||
if (window.electron) {
|
||||
window.electron.updateSettings(this.settingsForm.value);
|
||||
window.electron.updateSettings(settings);
|
||||
|
||||
// Set player paths if using external players
|
||||
if (this.settingsForm.value.mpvPlayerPath) {
|
||||
window.electron.setMpvPlayerPath(
|
||||
this.settingsForm.value.mpvPlayerPath
|
||||
);
|
||||
}
|
||||
if (this.settingsForm.value.vlcPlayerPath) {
|
||||
window.electron.setVlcPlayerPath(
|
||||
this.settingsForm.value.vlcPlayerPath
|
||||
);
|
||||
}
|
||||
window.electron.setMpvPlayerPath(mpvPlayerPath);
|
||||
window.electron.setVlcPlayerPath(vlcPlayerPath);
|
||||
}
|
||||
});
|
||||
if (this.isDialog) {
|
||||
@@ -467,6 +466,12 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
private normalizeExternalPlayerPath(
|
||||
playerPath: string | null | undefined
|
||||
): string {
|
||||
return playerPath?.trim() ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the changed settings to the app
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user