refactor: reset active channel when navigating back to the home view

This commit is contained in:
4gray committed 2023-02-24 12:59:55 +01:00
1 parent fa8ea4015c
commit a6d77db26b
3 files changed
+12

No files matched your search

@@ -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';
+4
View File
@@ -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 }>()
+6
View File
@@ -33,6 +33,12 @@ export const playlistReducer = createReducer(
};
}
),
on(PlaylistActions.resetActiveChannel, (state): PlaylistState => {
return {
...state,
active: undefined,
};
}),
on(
PlaylistActions.setCurrentEpgProgram,
(state, action): PlaylistState => ({