mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 17:36:15 -08:00
refactor: extend store related functionality
This commit is contained in:
1 parent
60961024ff
commit
d4a2741e45
4 files changed
+40
-1
No files matched your search
@@ -167,7 +167,11 @@ export class PlaylistEffects {
|
||||
this.playlistsService.addPlaylist(action.playlist)
|
||||
),
|
||||
tap((playlist) => {
|
||||
this.router.navigate(['/playlists/', playlist._id]);
|
||||
if (playlist.serverUrl) {
|
||||
this.router.navigate(['/xtreams/', playlist._id]);
|
||||
} else {
|
||||
this.router.navigate(['/playlists/', playlist._id]);
|
||||
}
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
@@ -181,6 +181,15 @@ export const playlistReducer = createReducer(
|
||||
title: action.playlist.title,
|
||||
autoRefresh: action.playlist.autoRefresh || false,
|
||||
userAgent: action.playlist.userAgent,
|
||||
...(action.playlist.serverUrl
|
||||
? { serverUrl: action.playlist.serverUrl }
|
||||
: {}),
|
||||
...(action.playlist.username
|
||||
? { username: action.playlist.username }
|
||||
: {}),
|
||||
...(action.playlist.password
|
||||
? { password: action.playlist.password }
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
state.playlists
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { getRouterSelectors } from '@ngrx/router-store';
|
||||
|
||||
export const {
|
||||
selectCurrentRoute,
|
||||
selectFragment,
|
||||
selectQueryParams,
|
||||
selectQueryParam,
|
||||
selectRouteParams,
|
||||
selectRouteParam,
|
||||
selectRouteData,
|
||||
selectRouteDataParam,
|
||||
selectUrl,
|
||||
selectTitle,
|
||||
} = getRouterSelectors();
|
||||
@@ -2,6 +2,7 @@ import { createFeatureSelector, createSelector } from '@ngrx/store';
|
||||
import { GLOBAL_FAVORITES_PLAYLIST_ID } from '../../../shared/constants';
|
||||
import * as fromPlaylistMetaState from './playlists.state';
|
||||
import * as fromPlaylistState from './reducers';
|
||||
import { selectRouteParam } from './router.selectors';
|
||||
import { PlaylistState } from './state';
|
||||
|
||||
export const selectPlaylistState =
|
||||
@@ -83,6 +84,17 @@ export const selectPlaylistEntities = createSelector(
|
||||
fromPlaylistMetaState.getPlaylistMetaEntities
|
||||
);
|
||||
|
||||
export const selectCurrentPlaylist = createSelector(
|
||||
selectPlaylistEntities,
|
||||
selectRouteParam('id'),
|
||||
(entities, id) => {
|
||||
if (entities) {
|
||||
return entities[id];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
export const selectFavorites = createSelector(
|
||||
selectPlaylistsMetaState,
|
||||
fromPlaylistMetaState.getPlaylistMetaEntities,
|
||||
|
||||
Reference in new issue
Block a user