refactor: code style and formatting

This commit is contained in:
4gray committed 2026-01-12 18:02:54 +01:00
1 parent b422cad260
commit 6cc9000a61
7 files changed
+98 -41

No files matched your search

@@ -1,6 +1,6 @@
export * from './with-portal.feature';
export * from './with-content.feature';
export * from './with-selection.feature';
export * from './with-search.feature';
export * from './with-epg.feature';
export * from './with-player.feature';
export * from './with-portal.feature';
export * from './with-search.feature';
export * from './with-selection.feature';
@@ -12,13 +12,12 @@ import {
XtreamSerieItem,
XtreamVodStream,
} from 'shared-interfaces';
import { ContentType } from '../../xtream-state';
import { XtreamCredentials } from '../../services/xtream-api.service';
import {
IXtreamDataSource,
XTREAM_DATA_SOURCE,
XtreamCategoryFromDb,
} from '../../data-sources/xtream-data-source.interface';
import { XtreamCredentials } from '../../services/xtream-api.service';
import { ContentType } from '../../xtream-state';
/**
* Content state for managing categories and streams
@@ -247,7 +246,11 @@ export function withContent() {
const ctx = getCredentialsFromStore();
if (!ctx) return;
patchState(store, { isImporting: true, importCount: 0, itemsToImport: 0 });
patchState(store, {
isImporting: true,
importCount: 0,
itemsToImport: 0,
});
try {
// Fetch categories first
@@ -261,8 +264,10 @@ export function withContent() {
const restoreData = localStorage.getItem(restoreKey);
if (restoreData) {
try {
const { favoritedXtreamIds, recentlyViewedXtreamIds } =
JSON.parse(restoreData);
const {
favoritedXtreamIds,
recentlyViewedXtreamIds,
} = JSON.parse(restoreData);
await dataSource.restoreUserData(
ctx.playlistId,
favoritedXtreamIds,
@@ -270,7 +275,10 @@ export function withContent() {
);
localStorage.removeItem(restoreKey);
} catch (err) {
console.error('Error restoring user data:', err);
console.error(
'Error restoring user data:',
err
);
}
}
} finally {
@@ -318,7 +326,9 @@ export function withContent() {
* Update import progress
*/
setImportProgress(count: number, total?: number): void {
const updates: Partial<ContentState> = { importCount: count };
const updates: Partial<ContentState> = {
importCount: count,
};
if (total !== undefined) {
updates.itemsToImport = total;
}
@@ -1,7 +1,15 @@
import { inject } from '@angular/core';
import { patchState, signalStoreFeature, withMethods, withState } from '@ngrx/signals';
import {
patchState,
signalStoreFeature,
withMethods,
withState,
} from '@ngrx/signals';
import { EpgItem } from 'shared-interfaces';
import { XtreamApiService, XtreamCredentials } from '../../services/xtream-api.service';
import {
XtreamApiService,
XtreamCredentials,
} from '../../services/xtream-api.service';
/**
* EPG state for managing Electronic Program Guide data
@@ -105,7 +113,11 @@ export function withEpg() {
}
try {
return await apiService.getShortEpg(credentials, streamId, 1);
return await apiService.getShortEpg(
credentials,
streamId,
1
);
} catch (error) {
console.error('Error loading channel EPG:', error);
return [];
@@ -1,9 +1,14 @@
import { inject } from '@angular/core';
import { patchState, signalStoreFeature, withMethods, withState } from '@ngrx/signals';
import {
patchState,
signalStoreFeature,
withMethods,
withState,
} from '@ngrx/signals';
import { XtreamSerieEpisode, XtreamVodDetails } from 'shared-interfaces';
import { PlayerService } from '../../../services/player.service';
import { XtreamUrlService } from '../../services/xtream-url.service';
import { XtreamCredentials } from '../../services/xtream-api.service';
import { XtreamUrlService } from '../../services/xtream-url.service';
/**
* Player state for managing stream URLs and player settings
@@ -100,7 +105,10 @@ export function withPlayer() {
return '';
}
const streamUrl = urlService.constructVodUrl(credentials, vodItem);
const streamUrl = urlService.constructVodUrl(
credentials,
vodItem
);
patchState(store, { streamUrl });
return streamUrl;
},
@@ -132,13 +140,15 @@ export function withPlayer() {
): void {
const playlist = getPlaylistFromStore();
const storeAny = store as any;
const contentType = storeAny.selectedContentType?.() || 'vod';
const contentType =
storeAny.selectedContentType?.() || 'vod';
playerService.openPlayer(
streamUrl,
title,
thumbnail,
localStorage.getItem('hideExternalInfoDialog') === 'true',
localStorage.getItem('hideExternalInfoDialog') ===
'true',
contentType === 'live',
playlist?.userAgent,
playlist?.referrer,
@@ -150,7 +160,10 @@ export function withPlayer() {
* Set hide external info dialog preference
*/
setHideExternalInfoDialog(hide: boolean): void {
localStorage.setItem('hideExternalInfoDialog', String(hide));
localStorage.setItem(
'hideExternalInfoDialog',
String(hide)
);
patchState(store, { hideExternalInfoDialog: hide });
},
@@ -161,7 +174,8 @@ export function withPlayer() {
patchState(store, {
streamUrl: null,
hideExternalInfoDialog:
localStorage.getItem('hideExternalInfoDialog') === 'true',
localStorage.getItem('hideExternalInfoDialog') ===
'true',
});
},
};
@@ -1,15 +1,22 @@
import { inject } from '@angular/core';
import { patchState, signalStoreFeature, withMethods, withState } from '@ngrx/signals';
import {
patchState,
signalStoreFeature,
withMethods,
withState,
} from '@ngrx/signals';
import { Store } from '@ngrx/store';
import { selectActivePlaylist } from 'm3u-state';
import { Playlist } from 'shared-interfaces';
import { PortalStatusType } from '../../xtream-state';
import { XtreamApiService, XtreamCredentials } from '../../services/xtream-api.service';
import {
IXtreamDataSource,
XTREAM_DATA_SOURCE,
XtreamPlaylistData,
} from '../../data-sources/xtream-data-source.interface';
import {
XtreamApiService,
XtreamCredentials,
} from '../../services/xtream-api.service';
import { PortalStatusType } from '../../xtream-state';
/**
* Portal state for managing playlist and portal status
@@ -63,7 +70,8 @@ export function withPortal() {
}
try {
const playlist = await dataSource.getPlaylist(playlistId);
const playlist =
await dataSource.getPlaylist(playlistId);
if (playlist) {
patchState(store, { currentPlaylist: playlist });
@@ -84,7 +92,9 @@ export function withPortal() {
};
await dataSource.createPlaylist(newPlaylist);
patchState(store, { currentPlaylist: newPlaylist });
patchState(store, {
currentPlaylist: newPlaylist,
});
}
}
} catch (error) {
@@ -109,7 +119,8 @@ export function withPortal() {
};
try {
const response = await apiService.getAccountInfo(credentials);
const response =
await apiService.getAccountInfo(credentials);
if (!response?.user_info?.status) {
patchState(store, { portalStatus: 'unavailable' });
@@ -1,8 +1,12 @@
import { inject } from '@angular/core';
import { patchState, signalStoreFeature, withMethods, withState } from '@ngrx/signals';
import {
patchState,
signalStoreFeature,
withMethods,
withState,
} from '@ngrx/signals';
import { GlobalSearchResult } from 'services';
import {
IXtreamDataSource,
XTREAM_DATA_SOURCE,
XtreamContentItem,
} from '../../data-sources/xtream-data-source.interface';
@@ -2,7 +2,6 @@ import { DatePipe } from '@angular/common';
import {
Component,
computed,
effect,
inject,
input,
output,
@@ -12,10 +11,10 @@ import {
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormsModule } from '@angular/forms';
import { MatIconButton } from '@angular/material/button';
import { MatRippleModule } from '@angular/material/core';
import { MatIcon } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatMenu, MatMenuModule, MatMenuTrigger } from '@angular/material/menu';
import { MatRippleModule } from '@angular/material/core';
import { NavigationEnd, Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { TranslatePipe } from '@ngx-translate/core';
@@ -115,22 +114,29 @@ export class PlaylistSwitcherComponent {
private async checkPortalStatuses(playlists: PlaylistMeta[]) {
const statusPromises = playlists
.filter(playlist => playlist.serverUrl && playlist.username && playlist.password)
.filter(
(playlist) =>
playlist.serverUrl && playlist.username && playlist.password
)
.map(async (playlist) => {
try {
const status = await this.portalStatusService.checkPortalStatus(
playlist.serverUrl,
playlist.username,
playlist.password
);
const status =
await this.portalStatusService.checkPortalStatus(
playlist.serverUrl,
playlist.username,
playlist.password
);
return { id: playlist._id, status };
} catch {
return { id: playlist._id, status: 'unavailable' as PortalStatus };
return {
id: playlist._id,
status: 'unavailable' as PortalStatus,
};
}
});
const results = await Promise.all(statusPromises);
const statusMap = new Map(results.map(r => [r.id, r.status]));
const statusMap = new Map(results.map((r) => [r.id, r.status]));
this.portalStatuses.set(statusMap);
}
@@ -186,4 +192,4 @@ export class PlaylistSwitcherComponent {
isSelected(playlist: PlaylistMeta): boolean {
return this.activePlaylistId() === playlist._id;
}
}
}