Skip to content

A platform for community discussion. Free, open, simple.

DEV: add channel hashtag style type (#33284)

David Battersbyf138f78f50b4
diff --git a/plugins/chat/lib/chat/channel_hashtag_data_source.rb b/plugins/chat/lib/chat/channel_hashtag_data_source.rb
index 6a1bebb8b66..e6de7d9d0e4 100644
--- a/plugins/chat/lib/chat/channel_hashtag_data_source.rb
+++ b/plugins/chat/lib/chat/channel_hashtag_data_source.rb
@@ -14,12 +14,17 @@ module Chat
"channel"
end
+ def self.style_type
+ "icon"
+ end
+
def self.channel_to_hashtag_item(guardian, channel)
HashtagAutocompleteService::HashtagItem.new.tap do |item|
item.text = channel.title
item.description = channel.description
item.slug = channel.slug
item.icon = icon
+ item.style_type = style_type
item.colors = [channel.category.color] if channel.category_channel?
item.relative_url = channel.relative_url
item.type = "channel"
diff --git a/plugins/chat/spec/lib/chat/channel_hashtag_data_source_spec.rb b/plugins/chat/spec/lib/chat/channel_hashtag_data_source_spec.rb
index 21f05445f05..c46f1b1246b 100644
--- a/plugins/chat/spec/lib/chat/channel_hashtag_data_source_spec.rb
+++ b/plugins/chat/spec/lib/chat/channel_hashtag_data_source_spec.rb
@@ -59,7 +59,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
text: "Zany Things",
description: "Just weird stuff",
colors: [channel1.chatable.color],
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
id: channel1.id,
type: "channel",
ref: nil,
@@ -83,7 +85,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
text: "Secret Stuff",
description: nil,
colors: [channel2.chatable.color],
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
id: channel2.id,
type: "channel",
ref: nil,
@@ -102,7 +106,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
text: "Zany Things",
description: "Just weird stuff",
colors: [channel1.chatable.color],
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
id: channel1.id,
type: "channel",
ref: nil,
@@ -123,7 +129,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
text: "Secret Stuff",
description: nil,
colors: [channel2.chatable.color],
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
id: channel2.id,
type: "channel",
ref: nil,
@@ -146,7 +154,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
expect(described_class.lookup(guardian, %w[music random]).map(&:to_h)).to contain_exactly(
{
description: "Just weird stuff",
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
colors: [category.color],
id: channel1.id,
ref: nil,
@@ -157,7 +167,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
},
{
description: "A place for music lovers",
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
colors: [category.color],
id: channel3.id,
ref: nil,
@@ -185,7 +197,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
text: "Zany Things",
description: "Just weird stuff",
colors: [channel1.chatable.color],
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
id: channel1.id,
type: "channel",
ref: nil,
@@ -202,7 +216,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
text: "Zany Things",
description: "Just weird stuff",
colors: [channel1.chatable.color],
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
id: channel1.id,
type: "channel",
ref: nil,
@@ -222,7 +238,9 @@ RSpec.describe Chat::ChannelHashtagDataSource do
text: "Secret Stuff",
description: nil,
colors: [channel2.chatable.color],
+ emoji: nil,
icon: "comment",
+ style_type: "icon",
id: channel2.id,
type: "channel",
ref: nil,