2017-11-20 22:18:00 +00:00
|
|
|
import * as types from '../actions/actionsTypes';
|
|
|
|
|
|
|
|
const initialState = {
|
2018-05-18 17:55:08 +00:00
|
|
|
usersTyping: []
|
2017-11-20 22:18:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function room(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2017-11-21 16:55:32 +00:00
|
|
|
case types.ROOM.OPEN:
|
|
|
|
return {
|
|
|
|
...initialState,
|
2018-01-15 18:44:20 +00:00
|
|
|
...action.room,
|
|
|
|
lastOpen: new Date()
|
|
|
|
};
|
|
|
|
case types.ROOM.CLOSE:
|
|
|
|
return {
|
|
|
|
...initialState
|
|
|
|
};
|
|
|
|
case types.ROOM.SET_LAST_OPEN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
lastOpen: action.date
|
2017-11-21 16:55:32 +00:00
|
|
|
};
|
2017-11-20 22:18:00 +00:00
|
|
|
case types.ROOM.ADD_USER_TYPING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
usersTyping: [...state.usersTyping.filter(user => user !== action.username), action.username]
|
|
|
|
};
|
|
|
|
case types.ROOM.REMOVE_USER_TYPING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
usersTyping: [...state.usersTyping.filter(user => user !== action.username)]
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|