bigbuffet-rw/app/soapbox/reducers/backups.js

28 lines
685 B
JavaScript
Raw Normal View History

2022-01-10 14:01:24 -08:00
import { Map as ImmutableMap, fromJS } from 'immutable';
2021-01-07 12:17:06 -08:00
import {
BACKUPS_FETCH_SUCCESS,
BACKUPS_CREATE_SUCCESS,
} from '../actions/backups';
const initialState = ImmutableMap();
const importBackup = (state, backup) => {
return state.set(backup.get('inserted_at'), backup);
};
const importBackups = (state, backups) => {
return state.withMutations(mutable => {
backups.forEach(backup => importBackup(mutable, backup));
});
};
export default function backups(state = initialState, action) {
switch(action.type) {
case BACKUPS_FETCH_SUCCESS:
case BACKUPS_CREATE_SUCCESS:
return importBackups(state, fromJS(action.backups));
default:
return state;
}
2021-08-03 12:22:51 -07:00
}