Add reaction deck remove api

This commit is contained in:
KMY 2023-05-26 18:53:55 +09:00
parent 1cf9bb24d7
commit c4efa4d986
6 changed files with 76 additions and 12 deletions

View file

@ -8,6 +8,10 @@ export const REACTION_DECK_UPDATE_REQUEST = 'REACTION_DECK_UPDATE_REQUEST';
export const REACTION_DECK_UPDATE_SUCCESS = 'REACTION_DECK_UPDATE_SUCCESS';
export const REACTION_DECK_UPDATE_FAIL = 'REACTION_DECK_UPDATE_FAIL';
export const REACTION_DECK_REMOVE_REQUEST = 'REACTION_DECK_REMOVE_REQUEST';
export const REACTION_DECK_REMOVE_SUCCESS = 'REACTION_DECK_REMOVE_SUCCESS';
export const REACTION_DECK_REMOVE_FAIL = 'REACTION_DECK_REMOVE_FAIL';
export function fetchReactionDeck() {
return (dispatch, getState) => {
dispatch(fetchReactionDeckRequest());
@ -77,3 +81,38 @@ export function updateReactionDeckFail(error) {
skipLoading: true,
};
}
export function removeReactionDeck(id) {
return (dispatch, getState) => {
dispatch(removeReactionDeckRequest());
api(getState).post('/api/v1/remove_reaction_deck', { emojis: [{ id }] }).then(response => {
dispatch(removeReactionDeckSuccess(response.data));
}).catch(error => {
dispatch(removeReactionDeckFail(error));
});
};
}
export function removeReactionDeckRequest() {
return {
type: REACTION_DECK_REMOVE_REQUEST,
skipLoading: true,
};
}
export function removeReactionDeckSuccess(emojis) {
return {
type: REACTION_DECK_REMOVE_SUCCESS,
emojis,
skipLoading: true,
};
}
export function removeReactionDeckFail(error) {
return {
type: REACTION_DECK_REMOVE_FAIL,
error,
skipLoading: true,
};
}