From a6d77db26bc452a4b74d52146fab4bccaf18f427 Mon Sep 17 00:00:00 2001 From: 4gray <4gray@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:59:55 +0100 Subject: [PATCH] refactor: reset active channel when navigating back to the home view --- .../components/video-player/sidebar/sidebar.component.ts | 2 ++ src/app/state/actions.ts | 4 ++++ src/app/state/reducers.ts | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/app/player/components/video-player/sidebar/sidebar.component.ts b/src/app/player/components/video-player/sidebar/sidebar.component.ts index e56e4aef5..edac9557f 100644 --- a/src/app/player/components/video-player/sidebar/sidebar.component.ts +++ b/src/app/player/components/video-player/sidebar/sidebar.component.ts @@ -3,6 +3,7 @@ import { Router } from '@angular/router'; import { Store } from '@ngrx/store'; import { Channel } from '../../../../../../shared/channel.interface'; import { DataService } from '../../../../services/data.service'; +import * as PlaylistActions from '../../../../state/actions'; import { selectPlaylistTitle } from '../../../../state/selectors'; import { SidebarView } from '../video-player.component'; @@ -28,6 +29,7 @@ export class SidebarComponent { goBack(): void { if (this.sidebarView === 'PLAYLISTS') { + this.store.dispatch(PlaylistActions.resetActiveChannel()); this.router.navigate(['/']); } else { this.sidebarView = 'PLAYLISTS'; diff --git a/src/app/state/actions.ts b/src/app/state/actions.ts index c6887a04e..dd5a62a10 100644 --- a/src/app/state/actions.ts +++ b/src/app/state/actions.ts @@ -71,6 +71,10 @@ export const setActiveChannel = createAction( props<{ channel: Channel }>() ); +export const resetActiveChannel = createAction( + `${STORE_KEY} Reset active channel` +); + export const setActiveChannelSuccess = createAction( `${STORE_KEY} Set active channel success`, props<{ channel: Channel }>() diff --git a/src/app/state/reducers.ts b/src/app/state/reducers.ts index 2f7bd3898..a8298d604 100644 --- a/src/app/state/reducers.ts +++ b/src/app/state/reducers.ts @@ -33,6 +33,12 @@ export const playlistReducer = createReducer( }; } ), + on(PlaylistActions.resetActiveChannel, (state): PlaylistState => { + return { + ...state, + active: undefined, + }; + }), on( PlaylistActions.setCurrentEpgProgram, (state, action): PlaylistState => ({