2017-08-17 06:28:41 +00:00
|
|
|
import * as types from '../actions/actionsTypes';
|
|
|
|
|
|
|
|
const initialState = {
|
|
|
|
isFetching: false,
|
2017-11-21 14:55:50 +00:00
|
|
|
failure: false,
|
|
|
|
message: {},
|
2017-11-24 20:44:52 +00:00
|
|
|
actionMessage: {},
|
2018-07-20 19:54:46 +00:00
|
|
|
replyMessage: {},
|
2017-11-21 14:55:50 +00:00
|
|
|
editing: false,
|
2017-12-13 15:00:26 +00:00
|
|
|
showActions: false,
|
2018-01-30 19:48:26 +00:00
|
|
|
showErrorActions: false,
|
|
|
|
showReactionPicker: false
|
2017-08-17 06:28:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function messages(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
|
|
|
case types.MESSAGES.REQUEST:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-08-17 06:28:41 +00:00
|
|
|
isFetching: true
|
|
|
|
};
|
|
|
|
case types.MESSAGES.SUCCESS:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-08-17 06:28:41 +00:00
|
|
|
isFetching: false
|
|
|
|
};
|
|
|
|
case types.LOGIN.FAILURE:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-08-17 06:28:41 +00:00
|
|
|
isFetching: false,
|
|
|
|
failure: true,
|
|
|
|
errorMessage: action.err
|
|
|
|
};
|
2017-11-24 20:44:52 +00:00
|
|
|
case types.MESSAGES.ACTIONS_SHOW:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
showActions: true,
|
|
|
|
actionMessage: action.actionMessage
|
|
|
|
};
|
|
|
|
case types.MESSAGES.ACTIONS_HIDE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
showActions: false
|
|
|
|
};
|
2017-12-13 15:00:26 +00:00
|
|
|
case types.MESSAGES.ERROR_ACTIONS_SHOW:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
showErrorActions: true,
|
|
|
|
actionMessage: action.actionMessage
|
|
|
|
};
|
|
|
|
case types.MESSAGES.ERROR_ACTIONS_HIDE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
showErrorActions: false
|
|
|
|
};
|
2017-11-21 14:55:50 +00:00
|
|
|
case types.MESSAGES.EDIT_INIT:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
message: action.message,
|
|
|
|
editing: true
|
|
|
|
};
|
2017-11-24 20:44:52 +00:00
|
|
|
case types.MESSAGES.EDIT_CANCEL:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
message: {},
|
|
|
|
editing: false
|
|
|
|
};
|
2017-11-21 14:55:50 +00:00
|
|
|
case types.MESSAGES.EDIT_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
message: {},
|
|
|
|
editing: false
|
|
|
|
};
|
|
|
|
case types.MESSAGES.EDIT_FAILURE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
message: {},
|
|
|
|
editing: false
|
|
|
|
};
|
2018-07-20 19:54:46 +00:00
|
|
|
case types.MESSAGES.REPLY_INIT:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
replyMessage: {
|
|
|
|
...action.message,
|
|
|
|
mention: action.mention
|
|
|
|
}
|
|
|
|
};
|
|
|
|
case types.MESSAGES.REPLY_CANCEL:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
replyMessage: {}
|
|
|
|
};
|
2017-11-21 14:55:50 +00:00
|
|
|
case types.MESSAGES.SET_INPUT:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
message: action.message
|
|
|
|
};
|
2017-11-24 20:44:52 +00:00
|
|
|
case types.MESSAGES.CLEAR_INPUT:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
message: {}
|
|
|
|
};
|
2018-01-30 19:48:26 +00:00
|
|
|
case types.MESSAGES.TOGGLE_REACTION_PICKER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
showReactionPicker: !state.showReactionPicker,
|
|
|
|
actionMessage: action.message
|
|
|
|
};
|
2017-08-17 06:28:41 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|