Skip to content

Commit

Permalink
Excluded youtube data from localstorage;
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhitex committed Dec 21, 2016
1 parent ef2ddb0 commit 95ee2b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { IAppState } from '../store';
import { NgRedux } from 'ng2-redux';
import { List } from 'immutable';
import { List, fromJS } from 'immutable';
import { ApiService } from '../services'
import { Observable, Subscription, Subject } from 'rxjs';
import { YoutubeService } from '../services';
Expand Down Expand Up @@ -140,7 +140,7 @@ export class YoutubeWindowActions {
changeVideo(playerId: string, videoId: string, dataExtractor: Observable<any>) {
const playerWindow = this.windowById(playerId);
let videoData: any;
var videoFound = playerWindow.videos.find((val, key, number) => {
var videoFound = fromJS(playerWindow.videos).find((val, key, number) => {
const sub = dataExtractor.subscribe((next) => {
videoData = next(val);
}, (err) => {
Expand Down Expand Up @@ -199,7 +199,7 @@ export class YoutubeWindowActions {

private windowById(playerId: string) {
const state = this.ngRedux.getState();
const playerWindow = state.youtubeWindows.playerWindows.filter((value, key) => value.playerId === playerId).first();
const playerWindow = fromJS(state.youtubeWindows.playerWindows).filter((value, key) => value.playerId === playerId).first();
if (typeof playerWindow === "undefined" || !playerWindow) {
console.log("NO PLAYER WINDOW..")
} else {
Expand Down
7 changes: 6 additions & 1 deletion src/RadioWatch/ClientApp/app/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ export const rootReducer = combineReducers<IAppState>({
appConfig: appConfigReducer
});

//remove youtube state from local storage..
function slicer(paths: any) {
return (state) => {
let subset = state;
let subset = {
phxGrid: state.phxGrid,
phxRmtGrid: state.phxRmtGrid,
appConfig: state.appConfig
};
return subset;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/RadioWatch/ClientApp/app/store/youtube-window-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export function youtubeWindowsReducer(state = INIT_STATE_WINDOWS, action): IYout
switch (action.type) {
case YOUTUBE_WINDOWS_ACTIONS.ADD_WINDOW:
return tassign(state, {
playerWindows: fromJS(state.playerWindows).push(tassign(INIT_STATE_WINDOW as IYoutubeWindowState, { playerId: ap }))
playerWindows: List<IYoutubeWindowState>(fromJS(state.playerWindows).push(tassign(INIT_STATE_WINDOW as IYoutubeWindowState, { playerId: ap })))
});
case YOUTUBE_WINDOWS_ACTIONS.REMOVE_WINDOW:
const index = state.playerWindows.findIndex((value, key) => value.playerId === ap);
return tassign(state, {
playerWindows: fromJS(state.playerWindows).remove(index)
playerWindows: List<IYoutubeWindowState>(fromJS(state.playerWindows).remove(index))
})
case YOUTUBE_WINDOW_ACTIONS.SEARCHING_IN_PROG:
case YOUTUBE_WINDOW_ACTIONS.SEARCHING_SUCCESS:
Expand All @@ -63,7 +63,7 @@ export function youtubeWindowsReducer(state = INIT_STATE_WINDOWS, action): IYout
case YOUTUBE_WINDOW_ACTIONS.PLAYER_LOADED:
case YOUTUBE_WINDOW_ACTIONS.PLAYER_STATE_CHANGE:
return tassign(state, {
playerWindows: fromJS(state.playerWindows).map(t => youtubeWindowReducer(t, action)).toList()
playerWindows: List<IYoutubeWindowState>(fromJS(state.playerWindows).map(t => youtubeWindowReducer(t, action)))
});
default:
return state;
Expand Down

0 comments on commit 95ee2b5

Please sign in to comment.