<commit_before>import { handleActions } from 'redux-actions';
import actions from "./actions";

const inital = {
 me: {
    id: "",
    name: "",
    authState: ""
  },
  room: {
    id: "",
    name: "",
    videos: [],
    owners: [],
    searchResults: [],
    queryVideo: "",
    submitstate: ""
  },
  user: {
    id: "",
    name: "",
    playList: []
  }
};

export default {
  me: handleActions({
    [actions.requestAuth](state) {
      return { ...state, authState: "pending" };
    },
    [actions.failureAuth](state, action) {
      return {...state, authState: action.payload}
    },
    [actions.successAuth](state, action) {
      const { id, name } = action.payload;
      return { id, name, authState: "completed" };
    }
  }),
  room: {
    [actions.successFetchRoomInfo](state, action) {
      return {...state, ...action.payload};
    },
    [actions.requestSerchVideo](state) {
      return {...state, submitstate: "pending"}
    },
    [actions.failureSearchVideo](state) {
      return {...state, submitstate: "error"}
    },
    [actions.sucessSearchVideo](state, action) {
      const { page, videos } = action.payload;
      const searchResults = [
        ...(page === 0 ? [] : state.searchResults),
        ...videos
      ];

      return {
        ...state,
         searchResults,
         submitstate: "complated"
      }
    },
    [actions.onPostedVideo](state, action) {
      const videos = [action.payload, ...state.videos];
      return {...state, videos};
    },
    [actions.onPlayedVideo](state, action) {
      const { index } = action.payload;
      const videos = [
        ...state.videos
          .slice(0, index)
          .map(value => ({...value, state: "unplayed"})),
        {...state.videos[index], state: "playing"},
        ...state.videos
          .slice(index)
          .map(value => ({...value, state: "played"}))
      ];
      return {...state, videos};<commit_msg>Fix post/search video reducers<commit_after>import { handleActions } from 'redux-actions';
import actions from "./actions";

const inital = {
 me: {
    id: "",
    name: "",
    authState: ""
  },
  room: {
    id: "",
    name: "",
    videos: [],
    owners: [],
    searchResults: [],
    queryVideo: "",
    submitstate: ""
  },
  user: {
    id: "",
    name: "",
    playList: []
  }
};

export default {
  me: handleActions({
    [actions.requestAuth](state) {
      return { ...state, authState: "pending" };
    },
    [actions.failureAuth](state, action) {
      return {...state, authState: action.payload}
    },
    [actions.successAuth](state, action) {
      const { id, name } = action.payload;
      return { id, name, authState: "completed" };
    }
  }),
  room: {
    [actions.successFetchRoomInfo](state, action) {
      return {...state, ...action.payload};
    },
    [actions.requestPostVideo](state) {
      return {
        ...state,
        submitting: {index: action.payload.index, state: "pending"}
      }
    },
    [actions.failurePostVideo](state) {
      return {
        ...state,
        submitting: {...state.submitting, state: "pending"}
      }
    },
    [actions.sucessPostVideo](state, action) {
      return {
        ...state,
        submitting: {...state.submitting, state: "completed"}
      }
    },
    [actions.sucessSearchVideo](state, action) {
      const { page, videos } = action.payload;
      const searchResults = [
        ...(page === 0 ? [] : state.searchResults),
        ...videos
      ];

      return {
        ...state,
         searchResults
      }
    },
    [actions.onPostedVideo](state, action) {
      const videos = [action.payload, ...state.videos];
      return {...state, videos};
    },
    [actions.onPlayedVideo](state, action) {
      const { index } = action.payload;
      const videos = [
        ...state.videos
          .slice(0, index)
          .map(value => ({...value, state: "unplayed"})),
        {...state.videos[index], state: "playing"},
        ...state.videos
          .slice(index)
          .map(value => ({...value, state: "played"}))
      ];
      return {...state, videos};
{'fraction_non_alphanumeric': 0.1815968841285297, 'fraction_numerical': 0.0009737098344693282, 'mean_word_length': 2.0324723247232472, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4395981', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1262, 'n_words': 253}