From 6cc9000a61a238fd83eeca002572cd900ae200ec Mon Sep 17 00:00:00 2001 From: 4gray Date: Mon, 12 Jan 2026 18:02:54 +0100 Subject: [PATCH] refactor: code style and formatting --- .../app/xtream-tauri/stores/features/index.ts | 6 ++-- .../stores/features/with-content.feature.ts | 26 +++++++++++------ .../stores/features/with-epg.feature.ts | 18 ++++++++++-- .../stores/features/with-player.feature.ts | 28 ++++++++++++++----- .../stores/features/with-portal.feature.ts | 25 ++++++++++++----- .../stores/features/with-search.feature.ts | 8 ++++-- .../playlist-switcher.component.ts | 28 +++++++++++-------- 7 files changed, 98 insertions(+), 41 deletions(-) diff --git a/apps/web/src/app/xtream-tauri/stores/features/index.ts b/apps/web/src/app/xtream-tauri/stores/features/index.ts index cfa95752e..5e7df6cf9 100644 --- a/apps/web/src/app/xtream-tauri/stores/features/index.ts +++ b/apps/web/src/app/xtream-tauri/stores/features/index.ts @@ -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'; diff --git a/apps/web/src/app/xtream-tauri/stores/features/with-content.feature.ts b/apps/web/src/app/xtream-tauri/stores/features/with-content.feature.ts index 6e5921d01..97d2981f4 100644 --- a/apps/web/src/app/xtream-tauri/stores/features/with-content.feature.ts +++ b/apps/web/src/app/xtream-tauri/stores/features/with-content.feature.ts @@ -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 = { importCount: count }; + const updates: Partial = { + importCount: count, + }; if (total !== undefined) { updates.itemsToImport = total; } diff --git a/apps/web/src/app/xtream-tauri/stores/features/with-epg.feature.ts b/apps/web/src/app/xtream-tauri/stores/features/with-epg.feature.ts index 2fcc85fd7..acebcb1df 100644 --- a/apps/web/src/app/xtream-tauri/stores/features/with-epg.feature.ts +++ b/apps/web/src/app/xtream-tauri/stores/features/with-epg.feature.ts @@ -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 []; diff --git a/apps/web/src/app/xtream-tauri/stores/features/with-player.feature.ts b/apps/web/src/app/xtream-tauri/stores/features/with-player.feature.ts index 93cf17d00..38bb78d89 100644 --- a/apps/web/src/app/xtream-tauri/stores/features/with-player.feature.ts +++ b/apps/web/src/app/xtream-tauri/stores/features/with-player.feature.ts @@ -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', }); }, }; diff --git a/apps/web/src/app/xtream-tauri/stores/features/with-portal.feature.ts b/apps/web/src/app/xtream-tauri/stores/features/with-portal.feature.ts index a4a07005e..032f35973 100644 --- a/apps/web/src/app/xtream-tauri/stores/features/with-portal.feature.ts +++ b/apps/web/src/app/xtream-tauri/stores/features/with-portal.feature.ts @@ -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' }); diff --git a/apps/web/src/app/xtream-tauri/stores/features/with-search.feature.ts b/apps/web/src/app/xtream-tauri/stores/features/with-search.feature.ts index b0305f643..fcc009566 100644 --- a/apps/web/src/app/xtream-tauri/stores/features/with-search.feature.ts +++ b/apps/web/src/app/xtream-tauri/stores/features/with-search.feature.ts @@ -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'; diff --git a/libs/ui/components/src/lib/playlist-switcher/playlist-switcher.component.ts b/libs/ui/components/src/lib/playlist-switcher/playlist-switcher.component.ts index 30c7639a5..bdf34c139 100644 --- a/libs/ui/components/src/lib/playlist-switcher/playlist-switcher.component.ts +++ b/libs/ui/components/src/lib/playlist-switcher/playlist-switcher.component.ts @@ -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; } -} \ No newline at end of file +}