mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-29 14:53:41 +01:00
change reaction api to match other interactions
Status reactions had an API similar to that of announcement reactions, using PUT and DELETE at a single endpoint. I believe that for statuses, it makes more sense to follow the convention of the other interactions and use separate POST endpoints for create and destroy respectively.
This commit is contained in:
parent
f4faa1b511
commit
a0d7cadcfd
4 changed files with 8 additions and 6 deletions
|
@ -7,7 +7,7 @@ class Api::V1::Statuses::ReactionsController < Api::BaseController
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
before_action :set_status
|
before_action :set_status
|
||||||
|
|
||||||
def update
|
def create
|
||||||
ReactService.new.call(current_account, @status, params[:id])
|
ReactService.new.call(current_account, @status, params[:id])
|
||||||
render_empty
|
render_empty
|
||||||
end
|
end
|
||||||
|
|
|
@ -416,7 +416,7 @@ export const addReaction = (statusId, name) => (dispatch, getState) => {
|
||||||
dispatch(addReactionRequest(statusId, name, alreadyAdded));
|
dispatch(addReactionRequest(statusId, name, alreadyAdded));
|
||||||
}
|
}
|
||||||
|
|
||||||
api(getState).put(`/api/v1/statuses/${statusId}/reactions/${name}`).then(() => {
|
api(getState).post(`/api/v1/statuses/${statusId}/react/${name}`).then(() => {
|
||||||
dispatch(addReactionSuccess(statusId, name, alreadyAdded));
|
dispatch(addReactionSuccess(statusId, name, alreadyAdded));
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (!alreadyAdded) {
|
if (!alreadyAdded) {
|
||||||
|
@ -450,7 +450,7 @@ export const addReactionFail = (statusId, name, error) => ({
|
||||||
export const removeReaction = (statusId, name) => (dispatch, getState) => {
|
export const removeReaction = (statusId, name) => (dispatch, getState) => {
|
||||||
dispatch(removeReactionRequest(statusId, name));
|
dispatch(removeReactionRequest(statusId, name));
|
||||||
|
|
||||||
api(getState).delete(`/api/v1/statuses/${statusId}/reactions/${name}`).then(() => {
|
api(getState).post(`/api/v1/statuses/${statusId}/unreact/${name}`).then(() => {
|
||||||
dispatch(removeReactionSuccess(statusId, name));
|
dispatch(removeReactionSuccess(statusId, name));
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
dispatch(removeReactionFail(statusId, name, err));
|
dispatch(removeReactionFail(statusId, name, err));
|
||||||
|
|
|
@ -436,7 +436,7 @@ export const addReaction = (statusId, name) => (dispatch, getState) => {
|
||||||
dispatch(addReactionRequest(statusId, name, alreadyAdded));
|
dispatch(addReactionRequest(statusId, name, alreadyAdded));
|
||||||
}
|
}
|
||||||
|
|
||||||
api(getState).put(`/api/v1/statuses/${statusId}/reactions/${name}`).then(() => {
|
api(getState).post(`/api/v1/statuses/${statusId}/react/${name}`).then(() => {
|
||||||
dispatch(addReactionSuccess(statusId, name, alreadyAdded));
|
dispatch(addReactionSuccess(statusId, name, alreadyAdded));
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (!alreadyAdded) {
|
if (!alreadyAdded) {
|
||||||
|
@ -470,7 +470,7 @@ export const addReactionFail = (statusId, name, error) => ({
|
||||||
export const removeReaction = (statusId, name) => (dispatch, getState) => {
|
export const removeReaction = (statusId, name) => (dispatch, getState) => {
|
||||||
dispatch(removeReactionRequest(statusId, name));
|
dispatch(removeReactionRequest(statusId, name));
|
||||||
|
|
||||||
api(getState).delete(`/api/v1/statuses/${statusId}/reactions/${name}`).then(() => {
|
api(getState).post(`/api/v1/statuses/${statusId}/unreact/${name}`).then(() => {
|
||||||
dispatch(removeReactionSuccess(statusId, name));
|
dispatch(removeReactionSuccess(statusId, name));
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
dispatch(removeReactionFail(statusId, name, err));
|
dispatch(removeReactionFail(statusId, name, err));
|
||||||
|
|
|
@ -442,6 +442,9 @@ Rails.application.routes.draw do
|
||||||
resource :favourite, only: :create
|
resource :favourite, only: :create
|
||||||
post :unfavourite, to: 'favourites#destroy'
|
post :unfavourite, to: 'favourites#destroy'
|
||||||
|
|
||||||
|
post '/react/:id', to: 'reactions#create'
|
||||||
|
post '/unreact/:id', to: 'reactions#destroy'
|
||||||
|
|
||||||
resource :bookmark, only: :create
|
resource :bookmark, only: :create
|
||||||
post :unbookmark, to: 'bookmarks#destroy'
|
post :unbookmark, to: 'bookmarks#destroy'
|
||||||
|
|
||||||
|
@ -453,7 +456,6 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resource :history, only: :show
|
resource :history, only: :show
|
||||||
resource :source, only: :show
|
resource :source, only: :show
|
||||||
resources :reactions, only: [:update, :destroy]
|
|
||||||
|
|
||||||
post :translate, to: 'translations#create'
|
post :translate, to: 'translations#create'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue