From ffdc68688cbcaec0105e104c742405a6e71917cf Mon Sep 17 00:00:00 2001 From: 4gray Date: Fri, 5 Apr 2024 21:53:35 +0200 Subject: [PATCH] feat(portals): add option to hide external player info dialog --- .../external-player-info-dialog.component.ts | 17 ++++++++-- .../stalker-main-container.component.ts | 20 ++++++------ src/app/xtream/portal.store.ts | 17 ++++++++++ .../xtream/xtream-main-container.component.ts | 32 ++++++++++++------- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/src/app/shared/components/external-player-info-dialog/external-player-info-dialog.component.ts b/src/app/shared/components/external-player-info-dialog/external-player-info-dialog.component.ts index a62c956a7..ef2e1ce14 100644 --- a/src/app/shared/components/external-player-info-dialog/external-player-info-dialog.component.ts +++ b/src/app/shared/components/external-player-info-dialog/external-player-info-dialog.component.ts @@ -1,9 +1,11 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; +import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatDialogModule } from '@angular/material/dialog'; import { MatIconModule } from '@angular/material/icon'; import { RouterLink } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; +import { PortalStore } from '../../../xtream/portal.store'; @Component({ standalone: true, @@ -31,7 +33,12 @@ import { TranslateModule } from '@ngx-translate/core'; - + +
+ Don't show anymore +
@@ -54,6 +61,7 @@ import { TranslateModule } from '@ngx-translate/core'; ], imports: [ MatButtonModule, + MatCheckboxModule, MatDialogModule, MatIconModule, RouterLink, @@ -61,7 +69,12 @@ import { TranslateModule } from '@ngx-translate/core'; ], }) export class ExternalPlayerInfoDialogComponent { + portalStore = inject(PortalStore); openUrl(url: string) { window.open(url, '_blank'); } + + setVisibility(value: boolean) { + this.portalStore.setHideExternalInfoDialog(value); + } } diff --git a/src/app/stalker/stalker-main-container.component.ts b/src/app/stalker/stalker-main-container.component.ts index 1dc06c780..00783762d 100644 --- a/src/app/stalker/stalker-main-container.component.ts +++ b/src/app/stalker/stalker-main-container.component.ts @@ -110,6 +110,8 @@ export class StalkerMainContainerComponent implements OnInit { }, */ ]; + hideExternalInfoDialog = this.portalStore.hideExternalInfoDialog; + currentCategoryId; //pagination @@ -346,12 +348,11 @@ export class StalkerMainContainerComponent implements OnInit { this.pageIndex = response.payload.js.cur_page; } else if (response.action === StalkerPortalActions.CreateLink) { let url = response.payload.js.cmd as string; - //url = url.replace('extension=ts', 'extension=m3u8'); if (url?.startsWith('ffmpeg')) { url = url.split(' ')[1]; } - this.openPlayer(url, response.payload.js.name); + this.openPlayer(url); } else if (response.action === StalkerPortalActions.Handshake) { const token = response.payload.js.token; sessionStorage.setItem(this.currentPlaylist()._id, token); @@ -370,15 +371,17 @@ export class StalkerMainContainerComponent implements OnInit { this.isLoading = false; } - openPlayer(streamUrl: string, title: string) { + openPlayer(streamUrl: string) { const player = this.settings().player; if (player === VideoPlayer.MPV) { - this.dialog.open(ExternalPlayerInfoDialogComponent); + if (!this.hideExternalInfoDialog()) + this.dialog.open(ExternalPlayerInfoDialogComponent); this.dataService.sendIpcEvent(OPEN_MPV_PLAYER, { url: streamUrl, }); } else if (player === VideoPlayer.VLC) { - this.dialog.open(ExternalPlayerInfoDialogComponent); + if (!this.hideExternalInfoDialog()) + this.dialog.open(ExternalPlayerInfoDialogComponent); this.dataService.sendIpcEvent(OPEN_VLC_PLAYER, { url: streamUrl, }); @@ -388,10 +391,7 @@ export class StalkerMainContainerComponent implements OnInit { { data: { streamUrl, - title: - title ?? - this.itemDetails?.info?.name ?? - this.itvTitle, + title: this.itvTitle, }, width: '80%', } @@ -472,6 +472,7 @@ export class StalkerMainContainerComponent implements OnInit { rating_kinopoisk: selectedContent.rating_kinopoisk, }, }; + this.itvTitle = item.name; this.breadcrumbs.push({ title: this.itemDetails?.info?.name, action: StalkerPortalActions.GetOrderedList, @@ -488,6 +489,7 @@ export class StalkerMainContainerComponent implements OnInit { name: string; }) { if (this.selectedContentType === ContentType.SERIES) { + this.itvTitle = item.name; this.getSerialDetails(item); return; } diff --git a/src/app/xtream/portal.store.ts b/src/app/xtream/portal.store.ts index 299e2a908..50d728f16 100644 --- a/src/app/xtream/portal.store.ts +++ b/src/app/xtream/portal.store.ts @@ -4,6 +4,7 @@ import { ComponentStore } from '@ngrx/component-store'; export interface PortalState { searchPhrase: string; content: any[]; + hideExternalInfoDialog: boolean; } @Injectable({ providedIn: 'root' }) @@ -12,12 +13,18 @@ export class PortalStore extends ComponentStore { super({ searchPhrase: '', content: [], + hideExternalInfoDialog: + localStorage.getItem('hideExternalInfoDialog') === 'true', }); } // selectors readonly searchPhrase = this.selectSignal((state) => state.searchPhrase); + readonly hideExternalInfoDialog = this.selectSignal( + (state) => state.hideExternalInfoDialog + ); + readonly getContentById = (id: string) => this.selectSignal((state) => state.content.find((i) => i.id === id)); @@ -35,4 +42,14 @@ export class PortalStore extends ComponentStore { content, }) ); + + readonly setHideExternalInfoDialog = this.updater( + (state, hideExternalInfoDialog: boolean): PortalState => { + localStorage.setItem( + 'hideExternalInfoDialog', + hideExternalInfoDialog.toString() + ); + return { ...state, hideExternalInfoDialog }; + } + ); } diff --git a/src/app/xtream/xtream-main-container.component.ts b/src/app/xtream/xtream-main-container.component.ts index 8a52acbe9..96c225dcc 100644 --- a/src/app/xtream/xtream-main-container.component.ts +++ b/src/app/xtream/xtream-main-container.component.ts @@ -142,6 +142,7 @@ export class XtreamMainContainerComponent implements OnInit { storage = inject(StorageMap); store = inject(Store); translate = inject(TranslateService); + currentPlaylist = this.store.selectSignal(selectCurrentPlaylist); navigationContentTypes: ContentTypeNavigationItem[] = [ { @@ -178,6 +179,7 @@ export class XtreamMainContainerComponent implements OnInit { errorViewInfo = { title: '', message: '' }; streamUrl: string; epgItems = []; + hideExternalInfoDialog = this.portalStore.hideExternalInfoDialog; commandsList = [ new IpcCommand(XTREAM_RESPONSE, (response: XtreamResponse) => @@ -302,9 +304,7 @@ export class XtreamMainContainerComponent implements OnInit { this.currentLayout = 'category_content'; } - itemClicked( - item: any /* XtreamLiveStream | XtreamVodStream | XtreamSerieItem */ - ) { + itemClicked(item: any) { let action; if (item.stream_type && item.stream_type === 'movie') { @@ -338,12 +338,14 @@ export class XtreamMainContainerComponent implements OnInit { openPlayer(streamUrl: string, title: string) { this.player = this.settings().player ?? VideoPlayer.VideoJs; if (this.player === VideoPlayer.MPV) { - this.dialog.open(ExternalPlayerInfoDialogComponent); + if (!this.hideExternalInfoDialog()) + this.dialog.open(ExternalPlayerInfoDialogComponent); this.dataService.sendIpcEvent(OPEN_MPV_PLAYER, { url: streamUrl, }); } else if (this.player === VideoPlayer.VLC) { - this.dialog.open(ExternalPlayerInfoDialogComponent); + if (!this.hideExternalInfoDialog()) + this.dialog.open(ExternalPlayerInfoDialogComponent); this.dataService.sendIpcEvent(OPEN_VLC_PLAYER, { url: streamUrl, }); @@ -484,9 +486,13 @@ export class XtreamMainContainerComponent implements OnInit { this.playlistService .addPortalFavorite(this.currentPlaylist()._id, item) .subscribe(() => { - this.snackBar.open('Added to favorites', null, { - duration: 1000, - }); + this.snackBar.open( + this.translate.instant('PORTALS.ADDED_TO_FAVORITES'), + null, + { + duration: 1000, + } + ); }); } @@ -494,9 +500,13 @@ export class XtreamMainContainerComponent implements OnInit { this.playlistService .removeFromPortalFavorites(this.currentPlaylist()._id, favoriteId) .subscribe(() => { - this.snackBar.open('Removed from favorites', null, { - duration: 1000, - }); + this.snackBar.open( + this.translate.instant('PORTALS.REMOVED_FROM_FAVORITES'), + null, + { + duration: 1000, + } + ); }); }