diff --git a/src/app/state/effects.ts b/src/app/state/effects.ts index b1ae3b1ac..be251e84a 100644 --- a/src/app/state/effects.ts +++ b/src/app/state/effects.ts @@ -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]); + } }) ); }, diff --git a/src/app/state/reducers.ts b/src/app/state/reducers.ts index 266c112bf..9a5c9a5cd 100644 --- a/src/app/state/reducers.ts +++ b/src/app/state/reducers.ts @@ -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 diff --git a/src/app/state/router.selectors.ts b/src/app/state/router.selectors.ts new file mode 100644 index 000000000..d1f5e38ff --- /dev/null +++ b/src/app/state/router.selectors.ts @@ -0,0 +1,14 @@ +import { getRouterSelectors } from '@ngrx/router-store'; + +export const { + selectCurrentRoute, + selectFragment, + selectQueryParams, + selectQueryParam, + selectRouteParams, + selectRouteParam, + selectRouteData, + selectRouteDataParam, + selectUrl, + selectTitle, +} = getRouterSelectors(); diff --git a/src/app/state/selectors.ts b/src/app/state/selectors.ts index 5fc2d67d4..e2da37157 100644 --- a/src/app/state/selectors.ts +++ b/src/app/state/selectors.ts @@ -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,