From be925276103da83172bf685c1156cbad1c325e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Tkaczy=C5=84ski?= Date: Thu, 26 Oct 2017 19:27:22 +0200 Subject: [PATCH] Remove uncovered branches related to file uploading --- src/post/Write/editorReducer.js | 17 ++------- src/user/userReducer.js | 61 --------------------------------- 2 files changed, 2 insertions(+), 76 deletions(-) diff --git a/src/post/Write/editorReducer.js b/src/post/Write/editorReducer.js index 88d0a00ab8..43482b9206 100644 --- a/src/post/Write/editorReducer.js +++ b/src/post/Write/editorReducer.js @@ -1,7 +1,6 @@ import * as authActions from '../../auth/authActions'; import * as editorActions from './editorActions'; import * as postActions from '../postActions'; -import * as userActions from '../../user/userActions'; const defaultState = { loading: false, @@ -18,10 +17,7 @@ const editor = (state = defaultState, action) => { case editorActions.ADD_EDITED_POST: return { ...state, - editedPosts: [ - ...state.editedPosts, - action.payload, - ], + editedPosts: [...state.editedPosts, action.payload], }; case postActions.GET_CONTENT_SUCCESS: return { @@ -86,10 +82,7 @@ const editor = (state = defaultState, action) => { case editorActions.DELETE_DRAFT_START: return { ...state, - pendingDrafts: [ - ...state.pendingDrafts, - action.meta.id, - ], + pendingDrafts: [...state.pendingDrafts, action.meta.id], }; case editorActions.DELETE_DRAFT_SUCCESS: { return { @@ -103,12 +96,6 @@ const editor = (state = defaultState, action) => { ...state, pendingDrafts: state.pendingDrafts.filter(id => id !== action.meta.id), }; - case userActions.UPLOAD_FILE_START: - return { ...state, loadingImg: true }; - - case userActions.UPLOAD_FILE_ERROR: - case userActions.UPLOAD_FILE_SUCCESS: - return { ...state, loadingImg: false }; default: return state; } diff --git a/src/user/userReducer.js b/src/user/userReducer.js index 6c6de76b32..f3ef8ddeb5 100644 --- a/src/user/userReducer.js +++ b/src/user/userReducer.js @@ -1,17 +1,6 @@ -import keyBy from 'lodash/keyBy'; -import omit from 'lodash/omit'; - import * as actions from './userActions'; const initialState = { - // Map - files: {}, - // Whether a file is uploading. - // Map - fileUploadIsLoading: {}, - fileUploadError: null, - filesFetchError: null, - filesFetchIsLoading: true, following: { list: [], pendingFollows: [], @@ -21,56 +10,6 @@ const initialState = { export default function userReducer(state = initialState, action) { switch (action.type) { - case actions.UPLOAD_FILE_START: { - return { - ...state, - fileUploadIsLoading: { - ...state.fileUploadIsLoading, - [action.meta.filename]: true, - }, - fileUploadError: null, - }; - } - case actions.UPLOAD_FILE_SUCCESS: { - return { - ...state, - files: { - ...state.files, - [action.payload.public_id]: action.payload, - }, - fileUploadIsLoading: omit(state.fileUploadIsLoading, [action.meta.filename]), - fileUploadError: null, - }; - } - case actions.UPLOAD_FILE_ERROR: { - return { - ...state, - fileUploadIsLoading: omit(state.fileUploadIsLoading, [action.meta.filename]), - fileUploadError: action.payload, - }; - } - case actions.FETCH_FILES_START: { - return { - ...state, - filesFetchIsLoading: true, - filesFetchError: null, - }; - } - case actions.FETCH_FILES_SUCCESS: { - return { - ...state, - files: keyBy(action.payload, 'public_id'), - filesFetchIsLoading: false, - filesFetchError: null, - }; - } - case actions.FETCH_FILES_ERROR: { - return { - ...state, - filesFetchIsLoading: false, - filesFetchError: action.payload, - }; - } case actions.GET_FOLLOWING_START: return { ...state,