Skip to content

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

DEV: remove chat channel icon (#36690)

David Battersbyfde576d8ec2b
diff --git a/plugins/chat/app/models/chat/category_channel.rb b/plugins/chat/app/models/chat/category_channel.rb
index 4f04ea08264..6694ee9b377 100644
--- a/plugins/chat/app/models/chat/category_channel.rb
+++ b/plugins/chat/app/models/chat/category_channel.rb
@@ -56,7 +56,6 @@ end
# messages_count :integer default(0), not null
# threading_enabled :boolean default(FALSE), not null
# last_message_id :bigint
-# icon_upload_id :integer
# emoji :string
#
# Indexes
diff --git a/plugins/chat/app/models/chat/channel.rb b/plugins/chat/app/models/chat/channel.rb
index 6c835add43c..9775f0d5f14 100644
--- a/plugins/chat/app/models/chat/channel.rb
+++ b/plugins/chat/app/models/chat/channel.rb
@@ -8,7 +8,7 @@ module Chat
# TODO (martin) Remove once we are using last_message instead,
# should be around August 2023.
- self.ignored_columns = %w[last_message_sent_at]
+ self.ignored_columns = %w[last_message_sent_at icon_upload_id]
self.table_name = "chat_channels"
belongs_to :chatable, polymorphic: true
@@ -28,7 +28,6 @@ module Chat
class_name: "Chat::Message",
foreign_key: :last_message_id,
optional: true
- has_one :icon_upload, class_name: "Upload", foreign_key: :id, primary_key: :icon_upload_id
def last_message
super || NullMessage.new
@@ -311,7 +310,6 @@ end
# messages_count :integer default(0), not null
# threading_enabled :boolean default(FALSE), not null
# last_message_id :bigint
-# icon_upload_id :integer
# emoji :string
#
# Indexes
diff --git a/plugins/chat/app/models/chat/direct_message_channel.rb b/plugins/chat/app/models/chat/direct_message_channel.rb
index 18a82dddac0..0908a9a53e2 100644
--- a/plugins/chat/app/models/chat/direct_message_channel.rb
+++ b/plugins/chat/app/models/chat/direct_message_channel.rb
@@ -64,7 +64,6 @@ end
# messages_count :integer default(0), not null
# threading_enabled :boolean default(FALSE), not null
# last_message_id :bigint
-# icon_upload_id :integer
# emoji :string
#
# Indexes
diff --git a/plugins/chat/app/serializers/chat/channel_serializer.rb b/plugins/chat/app/serializers/chat/channel_serializer.rb
index 16ea4b92133..68cdc5f1f5f 100644
--- a/plugins/chat/app/serializers/chat/channel_serializer.rb
+++ b/plugins/chat/app/serializers/chat/channel_serializer.rb
@@ -23,8 +23,7 @@ module Chat
:memberships_count,
:current_user_membership,
:meta,
- :threading_enabled,
- :icon_upload_url
+ :threading_enabled
has_one :last_message, serializer: Chat::LastMessageSerializer, embed: :objects
@@ -35,10 +34,6 @@ module Chat
@current_user_membership = opts[:membership]
end
- def icon_upload_url
- object.icon_upload&.url
- end
-
def include_emoji?
object.emoji.present?
end
diff --git a/plugins/chat/app/services/chat/create_category_channel.rb b/plugins/chat/app/services/chat/create_category_channel.rb
index d9e54b13376..3091d81b753 100644
--- a/plugins/chat/app/services/chat/create_category_channel.rb
+++ b/plugins/chat/app/services/chat/create_category_channel.rb
@@ -40,7 +40,6 @@ module Chat
attribute :category_id, :integer
attribute :auto_join_users, :boolean, default: false
attribute :threading_enabled, :boolean, default: false
- attribute :icon_upload_id, :integer
attribute :emoji, :string
before_validation do
@@ -83,15 +82,7 @@ module Chat
def create_channel(category:, params:)
category.create_chat_channel(
user_count: 1,
- **params.slice(
- :name,
- :slug,
- :icon_upload_id,
- :description,
- :auto_join_users,
- :threading_enabled,
- :emoji,
- ),
+ **params.slice(:name, :slug, :description, :auto_join_users, :threading_enabled, :emoji),
)
end
diff --git a/plugins/chat/app/services/chat/create_direct_message_channel.rb b/plugins/chat/app/services/chat/create_direct_message_channel.rb
index 28901846445..8c5527bb106 100644
--- a/plugins/chat/app/services/chat/create_direct_message_channel.rb
+++ b/plugins/chat/app/services/chat/create_direct_message_channel.rb
@@ -30,7 +30,6 @@ module Chat
attribute :target_usernames, :array
attribute :target_groups, :array
attribute :upsert, :boolean, default: false
- attribute :icon_upload_id, :integer
validate :target_presence
@@ -96,8 +95,7 @@ module Chat
end
def set_optional_params(channel:, params:)
- optional_params =
- params.slice(:name, :icon_upload_id).reject { |_, value| value.nil? || value == "" }
+ optional_params = params.slice(:name).reject { |_, value| value.nil? || value == "" }
channel.update!(optional_params) if !optional_params.empty?
end
diff --git a/plugins/chat/app/services/chat/update_channel.rb b/plugins/chat/app/services/chat/update_channel.rb
index cf03c59c75b..b8f949b8e5d 100644
--- a/plugins/chat/app/services/chat/update_channel.rb
+++ b/plugins/chat/app/services/chat/update_channel.rb
@@ -45,7 +45,6 @@ module Chat
attribute :threading_enabled, :boolean, default: false
attribute :auto_join_users, :boolean, default: false
attribute :allow_channel_wide_mentions, :boolean, default: true
- attribute :icon_upload_id, :integer, default: nil
attribute :emoji, :string
before_validation do
diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs b/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
index 0715e1676b7..8030169cdcb 100644
--- a/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
@@ -37,11 +37,7 @@ export default class ChatChannelIcon extends Component {
<template>
{{#if @channel.isDirectMessageChannel}}
- {{#if @channel.iconUploadUrl}}
- <div class="chat-channel-icon --avatar --custom-icon">
- <img src={{@channel.iconUploadUrl}} />
- </div>
- {{else if this.groupDirectMessage}}
+ {{#if this.groupDirectMessage}}
<div
class={{concatClass
"chat-channel-icon"
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
index f83d42caabb..57a1d7d068c 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
@@ -131,9 +131,7 @@ function createChannelLink(BaseCustomSidebarSectionLink, options = {}) {
get prefixType() {
if (this.isDM) {
- if (this.channel.iconUploadUrl) {
- return "image";
- } else if (this.channel.emoji) {
+ if (this.channel.emoji) {
return "emoji";
} else if (this.channel.chatable.group) {
return "text";
@@ -147,9 +145,7 @@ function createChannelLink(BaseCustomSidebarSectionLink, options = {}) {
get prefixValue() {
if (this.isDM) {
- if (this.channel.iconUploadUrl) {
- return this.channel.iconUploadUrl;
- } else if (this.channel.emoji) {
+ if (this.channel.emoji) {
return this.channel.emoji;
} else if (this.channel.chatable.group) {
return this.channel.membershipsCount;
@@ -750,9 +746,7 @@ export default {
}
get prefixType() {
- if (this.channel.iconUploadUrl) {
- return "image";
- } else if (this.channel.emoji) {
+ if (this.channel.emoji) {
return "emoji";
} else if (this.channel.chatable.group) {
return "text";
@@ -762,9 +756,7 @@ export default {
}
get prefixValue() {
- if (this.channel.iconUploadUrl) {
- return this.channel.iconUploadUrl;
- } else if (this.channel.emoji) {
+ if (this.channel.emoji) {
return this.channel.emoji;
} else if (this.channel.chatable.group) {
return this.channel.membershipsCount;
diff --git a/plugins/chat/assets/javascripts/discourse/models/chat-channel.js b/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
index 707382e9c74..966f668b505 100644
--- a/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
+++ b/plugins/chat/assets/javascripts/discourse/models/chat-channel.js
@@ -1,7 +1,6 @@
import { tracked } from "@glimmer/tracking";
import guid from "pretty-text/guid";
import { getOwnerWithFallback } from "discourse/lib/get-owner";
-import { getURLWithCDN } from "discourse/lib/get-url";
import { escapeExpression } from "discourse/lib/utilities";
import Category from "discourse/models/category";
import ChatMessagesManager from "discourse/plugins/chat/discourse/lib/chat-messages-manager";
@@ -98,9 +97,6 @@ export default class ChatChannel {
this.currentUserMembership = args.current_user_membership;
this.lastMessage = args.last_message;
this.meta = args.meta;
- this.iconUploadUrl = args.icon_upload_url
- ? getURLWithCDN(args.icon_upload_url)
- : null;
this.chatable = this.#initChatable(args.chatable ?? []);
this.tracking = new ChatTrackingState(getOwnerWithFallback(this));
diff --git a/plugins/chat/assets/stylesheets/common/chat-channel-icon.scss b/plugins/chat/assets/stylesheets/common/chat-channel-icon.scss
index d0af1a5f403..79a5c604f53 100644
--- a/plugins/chat/assets/stylesheets/common/chat-channel-icon.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-channel-icon.scss
@@ -64,12 +64,6 @@
}
}
- &.--custom-icon img {
- width: 24px;
- height: 24px;
- border-radius: 50%;
- }
-
&__restricted-category-icon {
background-color: var(--secondary);
position: absolute;
diff --git a/plugins/chat/lib/chat/channel_fetcher.rb b/plugins/chat/lib/chat/channel_fetcher.rb
index e452845c8de..9ac302a4e40 100644
--- a/plugins/chat/lib/chat/channel_fetcher.rb
+++ b/plugins/chat/lib/chat/channel_fetcher.rb
@@ -201,7 +201,6 @@ module Chat
.strict_loading
.where(id: scoped_channels)
.includes(
- :icon_upload,
last_message: [:uploads],
chatable: [{ direct_message_users: [user: %i[user_option group_users]] }, :users],
)
diff --git a/plugins/chat/spec/services/chat/create_category_channel_spec.rb b/plugins/chat/spec/services/chat/create_category_channel_spec.rb
index 24a732b08ff..7d7b3cd933d 100644
--- a/plugins/chat/spec/services/chat/create_category_channel_spec.rb
+++ b/plugins/chat/spec/services/chat/create_category_channel_spec.rb
@@ -14,9 +14,8 @@ RSpec.describe Chat::CreateCategoryChannel do
let(:category_id) { category.id }
let(:name) { "cool channel" }
- let(:icon_upload_id) { 2 }
let(:guardian) { Guardian.new(current_user) }
- let(:params) { { category_id:, name: name, icon_upload_id: icon_upload_id } }
+ let(:params) { { category_id:, name: name } }
let(:dependencies) { { guardian: } }
context "when public channels are disabled" do
@@ -56,7 +55,6 @@ RSpec.describe Chat::CreateCategoryChannel do
chatable: category,
name: name,
slug: "cool-channel",
- icon_upload_id: icon_upload_id,
)
end
diff --git a/plugins/chat/spec/services/chat/create_direct_message_channel_spec.rb b/plugins/chat/spec/services/chat/create_direct_message_channel_spec.rb
index ab613c40897..4f352821691 100644
--- a/plugins/chat/spec/services/chat/create_direct_message_channel_spec.rb
+++ b/plugins/chat/spec/services/chat/create_direct_message_channel_spec.rb
@@ -40,8 +40,7 @@ RSpec.describe Chat::CreateDirectMessageChannel do
let(:guardian) { Guardian.new(current_user) }
let(:target_usernames) { [user_1.username, user_2.username] }
let(:name) { "" }
- let(:icon_upload_id) { nil }
- let(:params) { { target_usernames:, name:, icon_upload_id: } }
+ let(:params) { { target_usernames:, name: } }
let(:dependencies) { { guardian: } }
context "when all steps pass" do
@@ -183,14 +182,6 @@ RSpec.describe Chat::CreateDirectMessageChannel do
expect(result.channel.name).to eq(name)
end
end
-
- context "when an icon_upload_id is given" do
- let(:icon_upload_id) { 2 }
-
- it "sets it as the channel icon_upload_id" do
- expect(result.channel.icon_upload_id).to eq(icon_upload_id)
- end
- end
end
context "when target_usernames exceeds chat_max_direct_message_users" do
diff --git a/plugins/chat/spec/services/chat/update_channel_spec.rb b/plugins/chat/spec/services/chat/update_channel_spec.rb
index 0310e8afd9b..811a42767cf 100644
--- a/plugins/chat/spec/services/chat/update_channel_spec.rb
+++ b/plugins/chat/spec/services/chat/update_channel_spec.rb
@@ -5,7 +5,6 @@ RSpec.describe Chat::UpdateChannel do
fab!(:channel, :chat_channel)
fab!(:current_user, :admin)
- fab!(:upload)
let(:guardian) { Guardian.new(current_user) }
let(:params) do
@@ -16,7 +15,6 @@ RSpec.describe Chat::UpdateChannel do
slug: "snail",
allow_channel_wide_mentions: true,
auto_join_users: false,
- icon_upload_id: upload.id,
}
end
let(:dependencies) { { guardian: } }
@@ -45,7 +43,6 @@ RSpec.describe Chat::UpdateChannel do
description: "a channel description",
allow_channel_wide_mentions: true,
auto_join_users: false,
- icon_upload_id: upload.id,
)
end