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

26 lines
714 B
JavaScript
Raw Normal View History

2022-01-10 14:01:24 -08:00
import { Map as ImmutableMap, fromJS } from 'immutable';
2021-10-09 14:56:03 -07:00
import {
STATUS_CREATE_REQUEST,
STATUS_CREATE_SUCCESS,
} from 'soapbox/actions/statuses';
const importStatus = (state, params, idempotencyKey) => {
return state.set(idempotencyKey, params);
};
const deleteStatus = (state, idempotencyKey) => state.delete(idempotencyKey);
const initialState = ImmutableMap();
export default function pending_statuses(state = initialState, action) {
switch (action.type) {
2022-05-11 14:06:35 -07:00
case STATUS_CREATE_REQUEST:
return importStatus(state, fromJS(action.params), action.idempotencyKey);
case STATUS_CREATE_SUCCESS:
return deleteStatus(state, action.idempotencyKey);
default:
return state;
2021-10-09 14:56:03 -07:00
}
}