mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-18 02:08:16 +00:00
Compare commits
5 Commits
ec16f39d46
...
37c25ebb7d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
37c25ebb7d | ||
![]() |
74fc4dbacf | ||
![]() |
6fb6b9fa4b | ||
![]() |
bfdaa9789a | ||
![]() |
f400360cf9 |
|
@ -2848,7 +2848,6 @@ a.account__display-name {
|
||||||
&__pane {
|
&__pane {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
pointer-events: none;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
min-width: 285px;
|
min-width: 285px;
|
||||||
|
@ -2860,7 +2859,6 @@ a.account__display-name {
|
||||||
&__inner {
|
&__inner {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 285px;
|
width: 285px;
|
||||||
pointer-events: auto;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,29 @@
|
||||||
class TagRelationshipsPresenter
|
class TagRelationshipsPresenter
|
||||||
attr_reader :following_map, :featuring_map
|
attr_reader :following_map, :featuring_map
|
||||||
|
|
||||||
def initialize(tags, current_account_id = nil, **options)
|
def initialize(tags, current_account_id = nil)
|
||||||
if current_account_id.nil?
|
if current_account_id.nil?
|
||||||
@following_map = {}
|
@following_map = {}
|
||||||
@featuring_map = {}
|
@featuring_map = {}
|
||||||
else
|
else
|
||||||
@following_map = TagFollow.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:following_map] || {})
|
@following_map = mapped_tag_follows(tags, current_account_id)
|
||||||
@featuring_map = FeaturedTag.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:featuring_map] || {})
|
@featuring_map = mapped_featured_tags(tags, current_account_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def mapped_tag_follows(tags, account_id)
|
||||||
|
TagFollow
|
||||||
|
.where(tag_id: tags.map(&:id), account_id: account_id)
|
||||||
|
.pluck(:tag_id)
|
||||||
|
.index_with(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def mapped_featured_tags(tags, account_id)
|
||||||
|
FeaturedTag
|
||||||
|
.where(tag_id: tags.map(&:id), account_id: account_id)
|
||||||
|
.pluck(:tag_id)
|
||||||
|
.index_with(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
40
spec/presenters/tag_relationships_presenter_spec.rb
Normal file
40
spec/presenters/tag_relationships_presenter_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe TagRelationshipsPresenter do
|
||||||
|
context 'without an account' do
|
||||||
|
subject { described_class.new(tags, nil) }
|
||||||
|
|
||||||
|
let(:tags) { Fabricate.times 2, :tag }
|
||||||
|
|
||||||
|
it 'includes empty hashes for maps' do
|
||||||
|
expect(subject)
|
||||||
|
.to have_attributes(
|
||||||
|
following_map: eq({}),
|
||||||
|
featuring_map: eq({})
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with an account and following and featured tags' do
|
||||||
|
subject { described_class.new(Tag.all, account.id) }
|
||||||
|
|
||||||
|
let(:account) { Fabricate :account }
|
||||||
|
let(:tag_to_feature) { Fabricate :tag }
|
||||||
|
let(:tag_to_follow) { Fabricate :tag }
|
||||||
|
|
||||||
|
before do
|
||||||
|
Fabricate :featured_tag, account: account, tag: tag_to_feature
|
||||||
|
Fabricate :tag_follow, account: account, tag: tag_to_follow
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'includes map with relevant id values' do
|
||||||
|
expect(subject)
|
||||||
|
.to have_attributes(
|
||||||
|
featuring_map: eq(tag_to_feature.id => true),
|
||||||
|
following_map: eq(tag_to_follow.id => true)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user