Cleaning up action names and compose drawer

This commit is contained in:
Eugen Rochko
2016-08-31 16:15:12 +02:00
parent 92afd29650
commit 72591cc6d5
29 changed files with 468 additions and 151 deletions

View File

@ -0,0 +1,25 @@
import { COMPOSE_CHANGE, COMPOSE_SUBMIT_REQUEST, COMPOSE_SUBMIT_SUCCESS, COMPOSE_SUBMIT_FAIL } from '../actions/compose';
import Immutable from 'immutable';
const initialState = Immutable.Map({
text: '',
in_reply_to_id: null,
isSubmitting: false
});
export default function compose(state = initialState, action) {
switch(action.type) {
case COMPOSE_CHANGE:
return state.set('text', action.text);
case COMPOSE_SUBMIT_REQUEST:
return state.set('isSubmitting', true);
case COMPOSE_SUBMIT_SUCCESS:
return state.withMutations(map => {
map.set('text', '').set('isSubmitting', false);
});
case COMPOSE_SUBMIT_FAIL:
return state.set('isSubmitting', false);
default:
return state;
}
}

View File

@ -1,8 +1,10 @@
import { combineReducers } from 'redux-immutable';
import statuses from './statuses';
import timelines from './timelines';
import meta from './meta';
import compose from './compose';
export default combineReducers({
statuses,
meta
timelines,
meta,
compose
});

View File

@ -1,11 +1,11 @@
import { SET_ACCESS_TOKEN } from '../actions/meta';
import { ACCESS_TOKEN_SET } from '../actions/meta';
import Immutable from 'immutable';
const initialState = Immutable.Map();
export default function meta(state = initialState, action) {
switch(action.type) {
case SET_ACCESS_TOKEN:
case ACCESS_TOKEN_SET:
return state.set('access_token', action.token);
default:
return state;

View File

@ -1,13 +1,13 @@
import { SET_TIMELINE, ADD_STATUS } from '../actions/statuses';
import Immutable from 'immutable';
import { TIMELINE_SET, TIMELINE_UPDATE } from '../actions/timelines';
import Immutable from 'immutable';
const initialState = Immutable.Map();
export default function statuses(state = initialState, action) {
export default function timelines(state = initialState, action) {
switch(action.type) {
case SET_TIMELINE:
case TIMELINE_SET:
return state.set(action.timeline, Immutable.fromJS(action.statuses));
case ADD_STATUS:
case TIMELINE_UPDATE:
return state.update(action.timeline, function (list) {
return list.unshift(Immutable.fromJS(action.status));
});