Remove unused code
This commit is contained in:
parent
b9dab37eac
commit
2292a61135
6 changed files with 5 additions and 87 deletions
|
@ -4,10 +4,10 @@ class Api::V1::ReactionDeckController < Api::BaseController
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:index]
|
before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:index]
|
||||||
before_action -> { doorkeeper_authorize! :write, :'write:lists' }, only: [:create, :remove]
|
before_action -> { doorkeeper_authorize! :write, :'write:lists' }, only: [:create]
|
||||||
|
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
before_action :set_deck, only: [:index, :create, :remove]
|
before_action :set_deck, only: [:index, :create]
|
||||||
|
|
||||||
rescue_from ArgumentError do |e|
|
rescue_from ArgumentError do |e|
|
||||||
render json: { error: e.to_s }, status: 422
|
render json: { error: e.to_s }, status: 422
|
||||||
|
@ -46,47 +46,6 @@ class Api::V1::ReactionDeckController < Api::BaseController
|
||||||
render json: remove_metas(deck)
|
render json: remove_metas(deck)
|
||||||
end
|
end
|
||||||
|
|
||||||
def legacy_create
|
|
||||||
deck = @deck
|
|
||||||
|
|
||||||
(deck_params['emojis'] || []).each do |data|
|
|
||||||
raise ArgumentError if data['id'].to_i >= 16 || data['id'].to_i.negative?
|
|
||||||
|
|
||||||
shortcode = data['emoji'].delete(':')
|
|
||||||
custom_emoji = CustomEmoji.find_by(shortcode: shortcode, domain: nil)
|
|
||||||
|
|
||||||
old = deck.find { |dd| dd['id'] == data['id'] }
|
|
||||||
emoji_data = old || { 'id' => data['id'] }
|
|
||||||
|
|
||||||
if custom_emoji
|
|
||||||
emoji_data['name'] = custom_emoji.shortcode
|
|
||||||
emoji_data['url'] = full_asset_url(custom_emoji.image.url)
|
|
||||||
emoji_data['static_url'] = full_asset_url(custom_emoji.image.url(:static))
|
|
||||||
emoji_data['width'] = custom_emoji.image_width
|
|
||||||
emoji_data['height'] = custom_emoji.image_height
|
|
||||||
emoji_data['custom_emoji_id'] = custom_emoji.id
|
|
||||||
else
|
|
||||||
emoji_data['name'] = shortcode
|
|
||||||
end
|
|
||||||
|
|
||||||
deck << emoji_data if old.nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
deck = deck.sort_by { |a| a['id'].to_i }
|
|
||||||
current_user.settings['reaction_deck'] = deck.to_json
|
|
||||||
current_user.save!
|
|
||||||
|
|
||||||
render json: remove_metas(deck)
|
|
||||||
end
|
|
||||||
|
|
||||||
def remove
|
|
||||||
deck = @deck.filter { |item| deck_params['emojis'].none? { |d| d['id'] == item['id'] } }
|
|
||||||
current_user.settings['reaction_deck'] = deck.to_json
|
|
||||||
current_user.save!
|
|
||||||
|
|
||||||
render json: remove_metas(deck)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_deck
|
def set_deck
|
||||||
|
|
|
@ -8,10 +8,6 @@ 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_SUCCESS = 'REACTION_DECK_UPDATE_SUCCESS';
|
||||||
export const REACTION_DECK_UPDATE_FAIL = 'REACTION_DECK_UPDATE_FAIL';
|
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() {
|
export function fetchReactionDeck() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(fetchReactionDeckRequest());
|
dispatch(fetchReactionDeckRequest());
|
||||||
|
@ -81,38 +77,3 @@ export function updateReactionDeckFail(error) {
|
||||||
skipLoading: true,
|
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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -81,4 +81,4 @@ class ReactionEmoji extends ImmutablePureComponent {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(injectIntl(ReactionEmoji));
|
export default connect()(injectIntl(ReactionEmoji));
|
||||||
|
|
|
@ -136,7 +136,6 @@ class ReactionDeck extends ImmutablePureComponent {
|
||||||
{(provided2) => (
|
{(provided2) => (
|
||||||
<div ref={provided2.innerRef} {...provided2.draggableProps} {...provided2.dragHandleProps}>
|
<div ref={provided2.innerRef} {...provided2.draggableProps} {...provided2.dragHandleProps}>
|
||||||
<ReactionEmoji emojiMap={emojiMap}
|
<ReactionEmoji emojiMap={emojiMap}
|
||||||
emojiId={emoji.get('id')}
|
|
||||||
emoji={emoji.get('name')}
|
emoji={emoji.get('name')}
|
||||||
index={index}
|
index={index}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { List as ImmutableList, fromJS as ConvertToImmutable } from 'immutable';
|
import { List as ImmutableList, fromJS as ConvertToImmutable } from 'immutable';
|
||||||
|
|
||||||
import { REACTION_DECK_FETCH_SUCCESS, REACTION_DECK_UPDATE_SUCCESS, REACTION_DECK_REMOVE_SUCCESS } from '../actions/reaction_deck';
|
import { REACTION_DECK_FETCH_SUCCESS, REACTION_DECK_UPDATE_SUCCESS } from '../actions/reaction_deck';
|
||||||
|
|
||||||
const initialState = ImmutableList([]);
|
const initialState = ImmutableList([]);
|
||||||
|
|
||||||
export default function reaction_deck(state = initialState, action) {
|
export default function reaction_deck(state = initialState, action) {
|
||||||
if(action.type === REACTION_DECK_FETCH_SUCCESS || action.type === REACTION_DECK_UPDATE_SUCCESS || action.type === REACTION_DECK_REMOVE_SUCCESS) {
|
if(action.type === REACTION_DECK_FETCH_SUCCESS || action.type === REACTION_DECK_UPDATE_SUCCESS) {
|
||||||
state = ConvertToImmutable(action.emojis);
|
state = ConvertToImmutable(action.emojis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ namespace :api, format: false do
|
||||||
|
|
||||||
resources :custom_emojis, only: [:index]
|
resources :custom_emojis, only: [:index]
|
||||||
resources :reaction_deck, only: [:index, :create]
|
resources :reaction_deck, only: [:index, :create]
|
||||||
post :remove_reaction_deck, to: 'reaction_deck#remove'
|
|
||||||
resources :suggestions, only: [:index, :destroy]
|
resources :suggestions, only: [:index, :destroy]
|
||||||
resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
|
resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
|
||||||
resources :preferences, only: [:index]
|
resources :preferences, only: [:index]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue