From 25875bf721e53a9a0c8397939d602cbc15674ef6 Mon Sep 17 00:00:00 2001 From: 4gray Date: Thu, 28 Nov 2024 23:31:50 +0100 Subject: [PATCH] refactor: simplify imports and enhance navigation bar Remove unused Angular common pipes and streamline imports in the `xtream-main-container.component.ts`. Introduce a settings button in the navigation bar for improved user access to settings. Update the settings retrieval method to use the `SettingsStore` service for better state management. --- .../stalker-main-container.component.ts | 57 +++++++-------- .../navigation-bar.component.html | 15 ++-- .../navigation-bar.component.ts | 69 ++++++++++++++----- .../xtream/xtream-main-container.component.ts | 36 ++-------- 4 files changed, 97 insertions(+), 80 deletions(-) diff --git a/src/app/stalker/stalker-main-container.component.ts b/src/app/stalker/stalker-main-container.component.ts index ca1f60634..8d9095f1a 100644 --- a/src/app/stalker/stalker-main-container.component.ts +++ b/src/app/stalker/stalker-main-container.component.ts @@ -370,33 +370,36 @@ export class StalkerMainContainerComponent implements OnInit { } openPlayer(streamUrl: string) { - const player = this.settings()?.player ?? VideoPlayer.VideoJs; - if (player === VideoPlayer.MPV) { - if (!this.hideExternalInfoDialog()) - this.dialog.open(ExternalPlayerInfoDialogComponent); - this.dataService.sendIpcEvent(OPEN_MPV_PLAYER, { - url: streamUrl, - mpvPlayerPath: this.settings()?.mpvPlayerPath, - }); - } else if (player === VideoPlayer.VLC) { - if (!this.hideExternalInfoDialog()) - this.dialog.open(ExternalPlayerInfoDialogComponent); - this.dataService.sendIpcEvent(OPEN_VLC_PLAYER, { - url: streamUrl, - vlcPlayerPath: this.settings()?.vlcPlayerPath, - }); - } else { - this.dialog.open( - PlayerDialogComponent, - { - data: { - streamUrl, - title: this.itvTitle, - }, - width: '80%', - } - ); - } + // Get fresh settings directly from storage instead of using signal + this.storage.get(STORE_KEY.Settings).subscribe((settings: Settings) => { + const player = settings?.player ?? VideoPlayer.VideoJs; + if (player === VideoPlayer.MPV) { + if (!this.hideExternalInfoDialog()) + this.dialog.open(ExternalPlayerInfoDialogComponent); + this.dataService.sendIpcEvent(OPEN_MPV_PLAYER, { + url: streamUrl, + mpvPlayerPath: settings?.mpvPlayerPath, + }); + } else if (player === VideoPlayer.VLC) { + if (!this.hideExternalInfoDialog()) + this.dialog.open(ExternalPlayerInfoDialogComponent); + this.dataService.sendIpcEvent(OPEN_VLC_PLAYER, { + url: streamUrl, + vlcPlayerPath: settings?.vlcPlayerPath, + }); + } else { + this.dialog.open( + PlayerDialogComponent, + { + data: { + streamUrl, + title: this.itvTitle, + }, + width: '80%', + } + ); + } + }); } categoryClicked(item: { category_name: string; category_id: string }) { diff --git a/src/app/xtream/navigation-bar/navigation-bar.component.html b/src/app/xtream/navigation-bar/navigation-bar.component.html index 03fb28251..cbe9d6eca 100644 --- a/src/app/xtream/navigation-bar/navigation-bar.component.html +++ b/src/app/xtream/navigation-bar/navigation-bar.component.html @@ -36,6 +36,11 @@ 'CHANNELS.FAVORITES' | translate }} + +
@@ -59,11 +64,7 @@ [matTooltip]="'TOP_MENU.TOGGLE_FAVORITE_FLAG' | translate" > - {{ - isFavoriteStream - ? 'star' - : 'star_outline' - }} + {{ isFavoriteStream ? 'star' : 'star_outline' }}
@@ -91,9 +92,7 @@ -
+