fix(web): address strict mode review feedback

This commit is contained in:
4gray committed 2026-05-22 03:11:14 +03:00
1 parent 4ab8915483
commit 5d355b6f10
7 files changed
+53 -13

No files matched your search

@@ -305,7 +305,7 @@ const electronApi = {
url: string,
title: string,
thumbnail: string,
userAgent: string,
userAgent: string | undefined,
referer?: string,
origin?: string,
contentInfo?: any,
@@ -328,7 +328,7 @@ const electronApi = {
url: string,
title: string,
thumbnail: string,
userAgent: string,
userAgent: string | undefined,
referer?: string,
origin?: string,
contentInfo?: any,
@@ -156,7 +156,7 @@ export class ElectronService extends DataService {
data.url,
data.title ?? '',
data.thumbnail ?? '',
data['user-agent'] ?? '',
data['user-agent'] ?? undefined,
data.referer ?? undefined,
data.origin ?? undefined,
data.contentInfo,
@@ -185,7 +185,7 @@ export class ElectronService extends DataService {
data.url,
data.title ?? '',
data.thumbnail ?? '',
data['user-agent'] ?? '',
data['user-agent'] ?? undefined,
data.referer ?? undefined,
data.origin ?? undefined,
data.contentInfo,
@@ -494,7 +494,9 @@ describe('SettingsComponent', () => {
.some((player) => player.id === VideoPlayer.EmbeddedMpv)
).toBe(false);
expect(resolveSupport).toBeDefined();
if (!resolveSupport) {
throw new Error('Expected embedded MPV support resolver');
}
resolveSupport({
supported: true,
platform: 'darwin',
@@ -983,4 +985,39 @@ describe('SettingsComponent', () => {
})
);
});
it('preserves saved EPG settings when saving from the web settings form', async () => {
fixture.destroy();
window.electron = undefined as unknown as typeof window.electron;
const mockStore = settingsStore as unknown as MockSettingsStore;
mockStore._setSettings({
epgUrl: ['https://example.com/guide.xml'],
preferUploadedEpgOverXtream: true,
});
mockStore.updateSettings.mockResolvedValue(undefined);
const webFixture = TestBed.createComponent(SettingsComponent);
const webComponent = webFixture.componentInstance;
webComponent.checkAppVersion = jest.fn();
webComponent.fetchLocalIpAddresses = jest
.fn()
.mockResolvedValue(undefined);
webFixture.detectChanges();
await webFixture.whenStable();
webComponent.settingsForm.patchValue({ theme: Theme.DarkTheme });
webComponent.onSubmit();
await webFixture.whenStable();
expect(mockStore.updateSettings).toHaveBeenCalledWith(
expect.objectContaining({
epgUrl: ['https://example.com/guide.xml'],
preferUploadedEpgOverXtream: true,
theme: Theme.DarkTheme,
})
);
webFixture.destroy();
});
});
@@ -496,12 +496,13 @@ export class SettingsComponent implements OnInit, OnDestroy {
}
private createSettingsFromFormValue(): Settings {
const currentSettings = this.settingsStore.getSettings();
const value = this.settingsForm.value;
const epgUrl = Array.isArray(value.epgUrl)
? value.epgUrl.filter(
(url): url is string => typeof url === 'string'
)
: [];
: (currentSettings.epgUrl ?? []);
return {
player: value.player ?? VideoPlayer.VideoJs,
@@ -533,7 +534,9 @@ export class SettingsComponent implements OnInit, OnDestroy {
coverSize: value.coverSize ?? 'medium',
epgUrl,
preferUploadedEpgOverXtream:
value.preferUploadedEpgOverXtream ?? false,
value.preferUploadedEpgOverXtream ??
currentSettings.preferUploadedEpgOverXtream ??
false,
};
}
+2 -2
View File
@@ -72,7 +72,7 @@ declare global {
url: string,
title: string,
thumbnail: string,
userAgent: string,
userAgent: string | undefined,
referer?: string,
origin?: string,
contentInfo?: unknown,
@@ -83,7 +83,7 @@ declare global {
url: string,
title: string,
thumbnail: string,
userAgent: string,
userAgent: string | undefined,
referer?: string,
origin?: string,
contentInfo?: unknown,
Vendored
+2 -2
View File
@@ -68,7 +68,7 @@ declare global {
url: string,
title: string,
thumbnail: string,
userAgent: string,
userAgent: string | undefined,
referer?: string,
origin?: string,
contentInfo?: any,
@@ -79,7 +79,7 @@ declare global {
url: string,
title: string,
thumbnail: string,
userAgent: string,
userAgent: string | undefined,
referer?: string,
origin?: string,
contentInfo?: any,
@@ -616,8 +616,8 @@ export class PwaXtreamDataSource implements IXtreamDataSource {
// Sort by updatedAt descending
playlistPositions.sort(
(a, b) =>
new Date(b.updatedAt ?? '').getTime() -
new Date(a.updatedAt ?? '').getTime()
new Date(b.updatedAt ?? 0).getTime() -
new Date(a.updatedAt ?? 0).getTime()
);
return limit ? playlistPositions.slice(0, limit) : playlistPositions;