From b0e3d611f585a1d86a0070c4da52a85015f31bac Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Mon, 9 Nov 2020 12:14:42 -0600 Subject: [PATCH] Removed unused code from initial_state and ReactController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Removed: - unused code from initial_state and ReactController --- app/controllers/react_controller.rb | 7 ++----- app/helpers/instance_helper.rb | 2 +- app/javascript/gabsocial/initial_state.js | 3 --- app/lib/proof_provider/keybase/config_serializer.rb | 2 +- app/models/setting.rb | 2 ++ app/presenters/initial_state_presenter.rb | 2 +- app/presenters/instance_presenter.rb | 5 +---- app/serializers/initial_state_serializer.rb | 6 ------ app/serializers/manifest_serializer.rb | 6 +++--- app/serializers/rest/instance_serializer.rb | 2 +- 10 files changed, 12 insertions(+), 25 deletions(-) diff --git a/app/controllers/react_controller.rb b/app/controllers/react_controller.rb index ce84c320..5295afcc 100644 --- a/app/controllers/react_controller.rb +++ b/app/controllers/react_controller.rb @@ -71,12 +71,9 @@ class ReactController < ApplicationController push_subscription: current_account.user.web_push_subscription(current_session), current_account: current_account, token: current_session.token, - admin: Account.find_local(Setting.site_contact_username.strip.gsub(/\A@/, '')), - } - else - { - admin: Account.find_local(Setting.site_contact_username.strip.gsub(/\A@/, '')), } + else + return {} end end diff --git a/app/helpers/instance_helper.rb b/app/helpers/instance_helper.rb index dd0b25f3..1940a1fa 100644 --- a/app/helpers/instance_helper.rb +++ b/app/helpers/instance_helper.rb @@ -2,7 +2,7 @@ module InstanceHelper def site_title - Setting.site_title + Setting::SITE_TITLE end def site_hostname diff --git a/app/javascript/gabsocial/initial_state.js b/app/javascript/gabsocial/initial_state.js index ad2716d3..a69b5515 100644 --- a/app/javascript/gabsocial/initial_state.js +++ b/app/javascript/gabsocial/initial_state.js @@ -13,12 +13,9 @@ export const boostModal = getMeta('boost_modal'); export const deleteModal = getMeta('delete_modal'); export const me = getMeta('me'); export const meUsername = getMeta('username'); -export const searchEnabled = getMeta('search_enabled'); -export const invitesEnabled = getMeta('invites_enabled'); export const repository = getMeta('repository'); export const source_url = getMeta('source_url'); export const version = getMeta('version'); -export const profile_directory = getMeta('profile_directory'); export const isStaff = getMeta('is_staff'); export const promotions = initialState && initialState.promotions; export const unreadCount = getMeta('unread_count'); diff --git a/app/lib/proof_provider/keybase/config_serializer.rb b/app/lib/proof_provider/keybase/config_serializer.rb index 9c945d2c..7e90120f 100644 --- a/app/lib/proof_provider/keybase/config_serializer.rb +++ b/app/lib/proof_provider/keybase/config_serializer.rb @@ -18,7 +18,7 @@ class ProofProvider::Keybase::ConfigSerializer < ActiveModel::Serializer end def display_name - Setting.site_title + Setting::SITE_TITLE end def logo diff --git a/app/models/setting.rb b/app/models/setting.rb index a5878e96..27080436 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -15,6 +15,8 @@ class Setting < RailsSettings::Base source Rails.root.join('config', 'settings.yml') + SITE_TITLE = 'Gab Social' + def to_param var end diff --git a/app/presenters/initial_state_presenter.rb b/app/presenters/initial_state_presenter.rb index 70c496be..a7fd80bc 100644 --- a/app/presenters/initial_state_presenter.rb +++ b/app/presenters/initial_state_presenter.rb @@ -2,5 +2,5 @@ class InitialStatePresenter < ActiveModelSerializers::Model attributes :settings, :push_subscription, :token, - :current_account, :admin, :text + :current_account, :text end diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb index 68f52cfb..b43024b1 100644 --- a/app/presenters/instance_presenter.rb +++ b/app/presenters/instance_presenter.rb @@ -51,8 +51,5 @@ class InstancePresenter def hero @hero ||= Rails.cache.fetch('site_uploads/hero') { SiteUpload.find_by(var: 'hero') } end - - def mascot - @mascot ||= Rails.cache.fetch('site_uploads/mascot') { SiteUpload.find_by(var: 'mascot') } - end + end diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index e76e97e5..b0352dd4 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -13,14 +13,9 @@ class InitialStateSerializer < ActiveModel::Serializer access_token: object.token, locale: I18n.locale, domain: Rails.configuration.x.local_domain, - admin: object.admin&.id&.to_s, - search_enabled: Chewy.enabled?, repository: GabSocial::Version.repository, source_url: GabSocial::Version.source_url, version: GabSocial::Version.to_s, - invites_enabled: Setting.min_invite_role == 'user', - mascot: instance_presenter.mascot&.file&.url, - profile_directory: Setting.profile_directory, } if object.current_account @@ -63,7 +58,6 @@ class InitialStateSerializer < ActiveModel::Serializer def accounts store = {} store[object.current_account.id.to_s] = ActiveModelSerializers::SerializableResource.new(object.current_account, serializer: REST::AccountSerializer) if object.current_account - store[object.admin.id.to_s] = ActiveModelSerializers::SerializableResource.new(object.admin, serializer: REST::AccountSerializer) if object.admin store end diff --git a/app/serializers/manifest_serializer.rb b/app/serializers/manifest_serializer.rb index 8472852d..5f6f51f0 100644 --- a/app/serializers/manifest_serializer.rb +++ b/app/serializers/manifest_serializer.rb @@ -10,15 +10,15 @@ class ManifestSerializer < ActiveModel::Serializer :share_target def name - object.site_title + 'Gab Social' end def short_name - object.site_title + 'Gab Social' end def description - strip_tags(object.site_short_description.presence || I18n.t('about.about_gabsocial_html')) + 'Gab is a social network that champions free speech, individual liberty and the free flow of information online. All are welcome.' end def icons diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 4debf1c4..bd56c904 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -16,7 +16,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer end def title - Setting.site_title + Setting::SITE_TITLE end def description