A platform for community discussion. Free, open, simple.
FIX: Unfollow not leave DM/group DM channels in chat sidebar menu (#37165)
Martin Brennanfe6dd5ed5388
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-menu.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-menu.gjsindex bea9cad4302..5282b8e08df 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-menu.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-menu.gjs@@ -35,10 +35,6 @@ export default class ChatChannelSidebarContextMenu extends Component {: "chat.channel_settings.star_channel";}- get isGroupChannel() {- return !!this.channel?.chatable?.group;- }-@actionasync toggleStarred() {if (!this.currentUserMembership || this.isTogglingStarred) {@@ -67,10 +63,10 @@ export default class ChatChannelSidebarContextMenu extends Component {@actionasync leaveChannel() {try {- if (this.isGroupChannel) {- await this.chatApi.leaveChannel(this.channel.id);- } else {+ if (this.channel.isDirectMessageChannel) {await this.chat.unfollowChannel(this.channel);+ } else {+ await this.chatApi.leaveChannel(this.channel.id);}this.currentUser.custom_fields.last_chat_channel_id = null;diff --git a/plugins/chat/spec/system/chat_channel_sidebar_context_menu_spec.rb b/plugins/chat/spec/system/chat_channel_sidebar_context_menu_spec.rbindex 5bc00cdfb57..5cf690b2b55 100644--- a/plugins/chat/spec/system/chat_channel_sidebar_context_menu_spec.rb+++ b/plugins/chat/spec/system/chat_channel_sidebar_context_menu_spec.rb@@ -86,6 +86,24 @@ RSpec.describe "Chat channel sidebar context menu", type: :system doexpect(page).to have_current_path(chat.channel_path(channel_1.slug, channel_1.id))endend++ context "when removing a group dm channel" do+ fab!(:group_dm_channel) do+ Fabricate(+ :direct_message_channel,+ users: [current_user, Fabricate(:user), Fabricate(:user)],+ )+ end++ it "removes the channel from sidebar but membership remains" do+ chat_page.visit_channel(group_dm_channel)+ chat_sidebar_page.remove_channel(group_dm_channel)++ expect(chat_sidebar_page).to have_no_channel(group_dm_channel)+ expect(group_dm_channel.membership_for(current_user)).to be_present+ expect(group_dm_channel.membership_for(current_user).following).to be_falsy+ end+ endendcontext "when changing notification settings" do