Compare commits

...

3 Commits

Author SHA1 Message Date
Matt Jankowski
1311ac3d5b
Merge f9c8c00523 into 74fc4dbacf 2025-07-15 17:05:58 +00:00
diondiondion
74fc4dbacf
refactor: Only remove pointer-events when necessary (#35390)
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Crowdin / Upload translations / upload-translations (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
2025-07-15 15:57:31 +00:00
Matt Jankowski
f9c8c00523 Extract Status::Mappings concern 2025-07-03 18:28:45 -04:00
5 changed files with 114 additions and 70 deletions

View File

@ -2848,7 +2848,6 @@ a.account__display-name {
&__pane {
height: 100%;
overflow: hidden;
pointer-events: none;
display: flex;
justify-content: flex-end;
min-width: 285px;
@ -2860,7 +2859,6 @@ a.account__display-name {
&__inner {
position: fixed;
width: 285px;
pointer-events: auto;
height: 100%;
}
}

View File

@ -0,0 +1,43 @@
# frozen_string_literal: true
module Status::Mappings
extend ActiveSupport::Concern
class_methods do
def bookmarks_map(status_ids, account_id)
Bookmark
.where(status_id: status_ids, account_id: account_id)
.pluck(:status_id)
.index_with(true)
end
def favourites_map(status_ids, account_id)
Favourite
.where(status_id: status_ids, account_id: account_id)
.pluck(:status_id)
.index_with(true)
end
def mutes_map(conversation_ids, account_id)
ConversationMute
.where(conversation_id: conversation_ids, account_id: account_id)
.pluck(:conversation_id)
.index_with(true)
end
def pins_map(status_ids, account_id)
StatusPin
.where(status_id: status_ids, account_id: account_id)
.pluck(:status_id)
.index_with(true)
end
def reblogs_map(status_ids, account_id)
Status
.unscoped
.where(reblog_of_id: status_ids, account_id: account_id)
.pluck(:reblog_of_id)
.index_with(true)
end
end
end

View File

@ -38,6 +38,7 @@ class Status < ApplicationRecord
include RateLimitable
include Status::FaspConcern
include Status::FetchRepliesConcern
include Status::Mappings
include Status::SafeReblogInsert
include Status::SearchConcern
include Status::SnapshotConcern
@ -353,26 +354,6 @@ class Status < ApplicationRecord
end
class << self
def favourites_map(status_ids, account_id)
Favourite.select(:status_id).where(status_id: status_ids).where(account_id: account_id).each_with_object({}) { |f, h| h[f.status_id] = true }
end
def bookmarks_map(status_ids, account_id)
Bookmark.select(:status_id).where(status_id: status_ids).where(account_id: account_id).to_h { |f| [f.status_id, true] }
end
def reblogs_map(status_ids, account_id)
unscoped.select(:reblog_of_id).where(reblog_of_id: status_ids).where(account_id: account_id).each_with_object({}) { |s, h| h[s.reblog_of_id] = true }
end
def mutes_map(conversation_ids, account_id)
ConversationMute.select(:conversation_id).where(conversation_id: conversation_ids).where(account_id: account_id).each_with_object({}) { |m, h| h[m.conversation_id] = true }
end
def pins_map(status_ids, account_id)
StatusPin.select(:status_id).where(status_id: status_ids).where(account_id: account_id).each_with_object({}) { |p, h| h[p.status_id] = true }
end
def from_text(text)
return [] if text.blank?

View File

@ -0,0 +1,70 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Status::Mappings do
describe '.bookmarks_map' do
subject { Status.bookmarks_map([status], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
context 'with a bookmarkeded status' do
before { Fabricate(:bookmark, account: account, status: status) }
it { is_expected.to be_a(Hash).and include(status.id => true) }
end
end
describe '.favourites_map' do
subject { Status.favourites_map([status], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
context 'with a favourited status' do
before { Fabricate(:favourite, status: status, account: account) }
it { is_expected.to be_a(Hash).and include(status.id => true) }
end
end
describe '.mutes_map' do
subject { Status.mutes_map([status.conversation.id], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
context 'with a muted conversation' do
before { account.mute_conversation!(status.conversation) }
it { is_expected.to be_a(Hash).and include(status.conversation_id => true) }
end
end
describe '.pins_map' do
subject { Status.pins_map([status], account) }
let(:status) { Fabricate(:status, account: account) }
let(:account) { Fabricate(:account) }
context 'with a pinned status' do
before { Fabricate(:status_pin, account: account, status: status) }
it { is_expected.to be_a(Hash).and include(status.id => true) }
end
end
describe '.reblogs_map' do
subject { Status.reblogs_map([status], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
context 'with a reblogged status' do
before { Fabricate(:status, account: account, reblog: status) }
it { is_expected.to be_a(Hash).and include(status.id => true) }
end
end
end

View File

@ -317,54 +317,6 @@ RSpec.describe Status do
end
end
describe '.mutes_map' do
subject { described_class.mutes_map([status.conversation.id], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
it 'returns a hash' do
expect(subject).to be_a Hash
end
it 'contains true value' do
account.mute_conversation!(status.conversation)
expect(subject[status.conversation.id]).to be true
end
end
describe '.favourites_map' do
subject { described_class.favourites_map([status], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
it 'returns a hash' do
expect(subject).to be_a Hash
end
it 'contains true value' do
Fabricate(:favourite, status: status, account: account)
expect(subject[status.id]).to be true
end
end
describe '.reblogs_map' do
subject { described_class.reblogs_map([status], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
it 'returns a hash' do
expect(subject).to be_a Hash
end
it 'contains true value' do
Fabricate(:status, account: account, reblog: status)
expect(subject[status.id]).to be true
end
end
describe '.only_reblogs' do
let!(:status) { Fabricate :status }
let!(:reblog) { Fabricate :status, reblog: Fabricate(:status) }