Skip to content

Commit

Permalink
Merge branch 'main' into temp3_for-taruntarun
Browse files Browse the repository at this point in the history
# Conflicts:
#	Gemfile.lock
  • Loading branch information
mayaeh committed May 16, 2024
2 parents 8d97354 + b2388be commit 2887ca9
Show file tree
Hide file tree
Showing 34 changed files with 113 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ group :test do
gem 'email_spec'

# Extra RSpec extension methods and helpers for sidekiq
gem 'rspec-sidekiq', '~> 4.0'
gem 'rspec-sidekiq', '~> 5.0'

# Browser integration testing
gem 'capybara', '~> 3.39'
Expand Down
12 changes: 7 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,8 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.6)
rexml (3.2.8)
strscan (>= 3.0.9)
rotp (6.3.0)
rouge (4.2.1)
rpam2 (4.0.2)
Expand All @@ -708,7 +709,7 @@ GEM
rspec-support (~> 3.13.0)
rspec-github (2.4.0)
rspec-core (~> 3.0)
rspec-mocks (3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.2)
Expand All @@ -719,7 +720,7 @@ GEM
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-sidekiq (4.2.0)
rspec-sidekiq (5.0.0)
rspec-core (~> 3.0)
rspec-expectations (~> 3.0)
rspec-mocks (~> 3.0)
Expand Down Expand Up @@ -776,7 +777,7 @@ GEM
scenic (1.8.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
selenium-webdriver (4.20.1)
selenium-webdriver (4.21.0)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
Expand Down Expand Up @@ -817,6 +818,7 @@ GEM
stringio (3.1.0)
strong_migrations (1.8.0)
activerecord (>= 5.2)
strscan (3.1.0)
swd (1.3.0)
activesupport (>= 3)
attr_required (>= 0.0.5)
Expand Down Expand Up @@ -1014,7 +1016,7 @@ DEPENDENCIES
rqrcode (~> 2.2)
rspec-github (~> 2.4)
rspec-rails (~> 6.0)
rspec-sidekiq (~> 4.0)
rspec-sidekiq (~> 5.0)
rspec_junit_formatter (~> 0.6)
rubocop
rubocop-capybara
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def show

limit = params[:limit].present? ? [params[:limit].to_i, PAGE_SIZE_MAX].min : PAGE_SIZE
@statuses = filtered_statuses.without_reblogs.limit(limit)
@statuses = cache_collection(@statuses, Status)
@statuses = preload_collection(@statuses, Status)
end

format.json do
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/activitypub/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def show
def set_items
case params[:id]
when 'featured'
@items = for_signed_account { cache_collection(@account.pinned_statuses, Status) }
@items = for_signed_account { preload_collection(@account.pinned_statuses, Status) }
@items = @items.map { |item| item.distributable? ? item : ActivityPub::TagManager.instance.uri_for(item) }
when 'tags'
@items = for_signed_account { @account.featured_tags }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/activitypub/outboxes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def prev_page
def set_statuses
return unless page_requested?

@statuses = cache_collection_paginated_by_id(
@statuses = preload_collection_paginated_by_id(
AccountStatusesFilter.new(@account, signed_request_account).results,
Status,
LIMIT,
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/accounts/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def set_account
end

def load_statuses
@account.unavailable? ? [] : cached_account_statuses
@account.unavailable? ? [] : preloaded_account_statuses
end

def cached_account_statuses
cache_collection_paginated_by_id(
def preloaded_account_statuses
preload_collection_paginated_by_id(
AccountStatusesFilter.new(@account, current_account, params).results,
Status,
limit_param(DEFAULT_STATUSES_LIMIT),
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def index
private

def load_statuses
cached_bookmarks
preloaded_bookmarks
end

def cached_bookmarks
cache_collection(results.map(&:status), Status)
def preloaded_bookmarks
preload_collection(results.map(&:status), Status)
end

def results
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/favourites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def index
private

def load_statuses
cached_favourites
preloaded_favourites
end

def cached_favourites
cache_collection(results.map(&:status), Status)
def preloaded_favourites
preload_collection(results.map(&:status), Status)
end

def results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def load_requests
)

NotificationRequest.preload_cache_collection(requests) do |statuses|
cache_collection(statuses, Status)
preload_collection(statuses, Status)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def load_notifications
)

Notification.preload_cache_collection_target_statuses(notifications) do |target_statuses|
cache_collection(target_statuses, Status)
preload_collection(target_statuses, Status)
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/api/v1/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class Api::V1::StatusesController < Api::BaseController
DESCENDANTS_DEPTH_LIMIT = 20

def index
@statuses = cache_collection(@statuses, Status)
@statuses = preload_collection(@statuses, Status)
render json: @statuses, each_serializer: REST::StatusSerializer
end

def show
cache_if_unauthenticated!
@status = cache_collection([@status], Status).first
@status = preload_collection([@status], Status).first
render json: @status, serializer: REST::StatusSerializer
end

Expand All @@ -51,8 +51,8 @@ def context

ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(ancestors_limit, current_account)
descendants_results = @status.descendants(descendants_limit, current_account, descendants_depth_limit)
loaded_ancestors = cache_collection(ancestors_results, Status)
loaded_descendants = cache_collection(descendants_results, Status)
loaded_ancestors = preload_collection(ancestors_results, Status)
loaded_descendants = preload_collection(descendants_results, Status)

@context = Context.new(ancestors: loaded_ancestors, descendants: loaded_descendants)
statuses = [@status] + @context.ancestors + @context.descendants
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/timelines/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def show
private

def load_statuses
cached_home_statuses
preloaded_home_statuses
end

def cached_home_statuses
cache_collection home_statuses, Status
def preloaded_home_statuses
preload_collection home_statuses, Status
end

def home_statuses
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/timelines/list_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def set_list
end

def set_statuses
@statuses = cached_list_statuses
@statuses = preloaded_list_statuses
end

def cached_list_statuses
cache_collection list_statuses, Status
def preloaded_list_statuses
preload_collection list_statuses, Status
end

def list_statuses
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/timelines/public_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def require_auth?
end

def load_statuses
cached_public_statuses_page
preloaded_public_statuses_page
end

def cached_public_statuses_page
cache_collection(public_statuses, Status)
def preloaded_public_statuses_page
preload_collection(public_statuses, Status)
end

def public_statuses
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/timelines/tag_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def load_tag
end

def load_statuses
cached_tagged_statuses
preloaded_tagged_statuses
end

def cached_tagged_statuses
@tag.nil? ? [] : cache_collection(tag_timeline_statuses, Status)
def preloaded_tagged_statuses
@tag.nil? ? [] : preload_collection(tag_timeline_statuses, Status)
end

def tag_timeline_statuses
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/trends/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def enabled?

def set_statuses
@statuses = if enabled?
cache_collection(statuses_from_trends.offset(offset_param).limit(limit_param(DEFAULT_STATUSES_LIMIT)), Status)
preload_collection(statuses_from_trends.offset(offset_param).limit(limit_param(DEFAULT_STATUSES_LIMIT)), Status)
else
[]
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base
include UserTrackingConcern
include SessionTrackingConcern
include CacheConcern
include PreloadingConcern
include DomainControlHelper
include DatabaseHelper
include AuthorizedFetchHelper
Expand Down
16 changes: 0 additions & 16 deletions app/controllers/concerns/cache_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,4 @@ def render_with_cache(**options)
Rails.cache.write(key, response.body, expires_in: expires_in, raw: true)
end
end

# TODO: Rename this method, as it does not perform any caching anymore.
def cache_collection(raw, klass)
return raw unless klass.respond_to?(:preload_cacheable_associations)

records = raw.to_a

klass.preload_cacheable_associations(records)

records
end

# TODO: Rename this method, as it does not perform any caching anymore.
def cache_collection_paginated_by_id(raw, klass, limit, options)
cache_collection raw.to_a_paginated_by_id(limit, options), klass
end
end
17 changes: 17 additions & 0 deletions app/controllers/concerns/preloading_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module PreloadingConcern
extend ActiveSupport::Concern

def preload_collection(scope, klass)
return scope unless klass.respond_to?(:preload_cacheable_associations)

scope.to_a.tap do |records|
klass.preload_cacheable_associations(records)
end
end

def preload_collection_paginated_by_id(scope, klass, limit, options)
preload_collection scope.to_a_paginated_by_id(limit, options), klass
end
end
2 changes: 1 addition & 1 deletion app/controllers/settings/applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def show; end
def new
@application = Doorkeeper::Application.new(
redirect_uri: Doorkeeper.configuration.native_redirect_uri,
scopes: 'read write follow'
scopes: 'read:me'
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def set_local
end

def set_statuses
@statuses = cache_collection(TagFeed.new(@tag, nil, local: @local).get(limit_param), Status)
@statuses = preload_collection(TagFeed.new(@tag, nil, local: @local).get(limit_param), Status)
end

def limit_param
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function changeSetting(path, value) {
}

const debouncedSave = debounce((dispatch, getState) => {
if (getState().getIn(['settings', 'saved'])) {
if (getState().getIn(['settings', 'saved']) || !getState().getIn(['meta', 'me'])) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/locales/gl.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"block_modal.remote_users_caveat": "Ímoslle pedir ao servidor {domain} que respecte a túa decisión. Emporiso, non hai garantía de que atenda a petición xa que os servidores xestionan os bloqueos de formas diferentes. As publicacións públicas poderían aínda ser visibles para usuarias que non iniciaron sesión.",
"block_modal.show_less": "Mostrar menos",
"block_modal.show_more": "Mostrar máis",
"block_modal.they_cant_mention": "Non te pode seguir nin mencionar.",
"block_modal.they_cant_mention": "Non te poden seguir nin mencionar.",
"block_modal.they_cant_see_posts": "Non pode ver as túas publicacións nin ti as de ela.",
"block_modal.they_will_know": "Pode ver que a bloqueaches.",
"block_modal.title": "Bloquear usuaria?",
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/mastodon/locales/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
"follow_suggestions.personalized_suggestion": "Prispôsobený návrh",
"follow_suggestions.popular_suggestion": "Obľúbený návrh",
"follow_suggestions.popular_suggestion_longer": "Populárne na {domain}",
"follow_suggestions.similar_to_recently_followed_longer": "Podobné profilom ktoré si nedávno nasledoval/a",
"follow_suggestions.similar_to_recently_followed_longer": "Podobné profilom, ktoré si nedávno nasledoval/a",
"follow_suggestions.view_all": "Zobraziť všetky",
"follow_suggestions.who_to_follow": "Koho sledovať",
"followed_tags": "Sledované hashtagy",
Expand Down Expand Up @@ -446,6 +446,7 @@
"notification.follow_request": "{name} vás žiada sledovať",
"notification.mention": "{name} vás spomína",
"notification.moderation-warning.learn_more": "Zisti viac",
"notification.moderation_warning.action_disable": "Tvoj účet bol vypnutý.",
"notification.moderation_warning.action_silence": "Tvoj účet bol obmedzený.",
"notification.moderation_warning.action_suspend": "Tvoj účet bol pozastavený.",
"notification.own_poll": "Vaša anketa sa skončila",
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
"notification.follow_request": "{name} size takip isteği gönderdi",
"notification.mention": "{name} senden bahsetti",
"notification.moderation-warning.learn_more": "Daha fazlası",
"notification.moderation_warning": "Bir denetim uyarısı aldınız",
"notification.moderation_warning": "Hesabınız bir denetim uyarısı aldı",
"notification.moderation_warning.action_delete_statuses": "Bazı gönderileriniz kaldırıldı.",
"notification.moderation_warning.action_disable": "Hesabınız devre dışı bırakıldı.",
"notification.moderation_warning.action_mark_statuses_as_sensitive": "Bazı gönderileriniz hassas olarak işaretlendi.",
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4366,10 +4366,6 @@ a.status-card {
outline: $ui-button-focus-outline;
}

.no-reduce-motion .icon {
transition: transform 0.15s ease-in-out;
}

&.active {
color: $primary-text-color;

Expand All @@ -4388,6 +4384,10 @@ a.status-card {
}
}

.no-reduce-motion .column-header__button .icon {
transition: transform 150ms ease-in-out;
}

.column-header__collapsible {
max-height: 70vh;
overflow: hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ def mastodon_version
end

def ruby_version
yjit = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
value = "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}#{yjit ? ' +YJIT' : ''}"

{
key: 'ruby',
human_key: 'Ruby',
value: value,
human_value: value,
value: "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}",
human_value: RUBY_DESCRIPTION,
}
end

Expand Down
Loading

0 comments on commit 2887ca9

Please sign in to comment.