2018-03-23 16:49:51 +00:00
|
|
|
import { SNIPPETED_MESSAGES } from '../actions/actionsTypes';
|
|
|
|
|
|
|
|
const initialState = {
|
2018-04-24 19:34:03 +00:00
|
|
|
messages: [],
|
|
|
|
ready: false
|
2018-03-23 16:49:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function server(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2018-04-24 19:34:03 +00:00
|
|
|
case SNIPPETED_MESSAGES.OPEN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
ready: false
|
|
|
|
};
|
|
|
|
case SNIPPETED_MESSAGES.READY:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
ready: true
|
|
|
|
};
|
2018-03-23 16:49:51 +00:00
|
|
|
case SNIPPETED_MESSAGES.MESSAGES_RECEIVED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
messages: [...state.messages, ...action.messages]
|
|
|
|
};
|
|
|
|
case SNIPPETED_MESSAGES.CLOSE:
|
|
|
|
return initialState;
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|