2016-11-10 14:26:24 +01:00
|
|
|
import { List, Map as $Map } from 'immutable';
|
2021-01-06 21:47:39 +01:00
|
|
|
import { RECEIVE_ARCHIVE, REVIVE_TOGGLE } from './actions';
|
|
|
|
import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
|
2016-11-10 14:26:24 +01:00
|
|
|
|
2017-08-28 19:15:47 +02:00
|
|
|
function getInitState() {
|
2016-11-10 14:26:24 +01:00
|
|
|
return new $Map({ list: new List() });
|
|
|
|
}
|
|
|
|
|
|
|
|
const archiveStore = (state = getInitState(), action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case REVIVE_TOGGLE:
|
2017-08-28 21:40:44 +02:00
|
|
|
return state.update('list', list => list.filter(item => item.name !== action.value));
|
2016-11-10 14:26:24 +01:00
|
|
|
case RECEIVE_ARCHIVE:
|
|
|
|
return state.set('list', new List(action.value));
|
2020-05-14 22:33:36 +02:00
|
|
|
case USER_LOGOUT:
|
2020-05-18 20:53:17 +02:00
|
|
|
case USER_LOGIN:
|
2020-05-14 22:33:36 +02:00
|
|
|
return getInitState();
|
2016-11-10 14:26:24 +01:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default archiveStore;
|