From 2292a611357931f0f11cfc667bd39b4841e53dab Mon Sep 17 00:00:00 2001 From: KMY Date: Fri, 26 May 2023 21:16:35 +0900 Subject: [PATCH] Remove unused code --- .../api/v1/reaction_deck_controller.rb | 45 +------------------ .../mastodon/actions/reaction_deck.js | 39 ---------------- .../components/reaction_emoji.jsx | 2 +- .../mastodon/features/reaction_deck/index.jsx | 1 - .../mastodon/reducers/reaction_deck.js | 4 +- config/routes/api.rb | 1 - 6 files changed, 5 insertions(+), 87 deletions(-) diff --git a/app/controllers/api/v1/reaction_deck_controller.rb b/app/controllers/api/v1/reaction_deck_controller.rb index a65cd33e7f..fe74738d4b 100644 --- a/app/controllers/api/v1/reaction_deck_controller.rb +++ b/app/controllers/api/v1/reaction_deck_controller.rb @@ -4,10 +4,10 @@ class Api::V1::ReactionDeckController < Api::BaseController include RoutingHelper 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 :set_deck, only: [:index, :create, :remove] + before_action :set_deck, only: [:index, :create] rescue_from ArgumentError do |e| render json: { error: e.to_s }, status: 422 @@ -46,47 +46,6 @@ class Api::V1::ReactionDeckController < Api::BaseController render json: remove_metas(deck) 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 def set_deck diff --git a/app/javascript/mastodon/actions/reaction_deck.js b/app/javascript/mastodon/actions/reaction_deck.js index c1a1b0146e..11510d5d0d 100644 --- a/app/javascript/mastodon/actions/reaction_deck.js +++ b/app/javascript/mastodon/actions/reaction_deck.js @@ -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_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()); @@ -81,38 +77,3 @@ 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, - }; -} diff --git a/app/javascript/mastodon/features/reaction_deck/components/reaction_emoji.jsx b/app/javascript/mastodon/features/reaction_deck/components/reaction_emoji.jsx index d221ef857c..7fb6f49285 100644 --- a/app/javascript/mastodon/features/reaction_deck/components/reaction_emoji.jsx +++ b/app/javascript/mastodon/features/reaction_deck/components/reaction_emoji.jsx @@ -81,4 +81,4 @@ class ReactionEmoji extends ImmutablePureComponent { } -export default connect(injectIntl(ReactionEmoji)); +export default connect()(injectIntl(ReactionEmoji)); diff --git a/app/javascript/mastodon/features/reaction_deck/index.jsx b/app/javascript/mastodon/features/reaction_deck/index.jsx index feb309b804..0de2fdb98b 100644 --- a/app/javascript/mastodon/features/reaction_deck/index.jsx +++ b/app/javascript/mastodon/features/reaction_deck/index.jsx @@ -136,7 +136,6 @@ class ReactionDeck extends ImmutablePureComponent { {(provided2) => (