From 5747b910e61d9ec44018ae3e486027723026c00d Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 18 Dec 2024 15:55:02 +0100 Subject: [PATCH] FIX: Unpinning topics in glimmer topic list (#30342) it's already handled by TopicStatus component (so one was undoing the other's toggle) --- .../discourse/app/components/topic-list/item.gjs | 9 --------- spec/system/topic_list/glimmer_spec.rb | 13 +++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/topic-list/item.gjs b/app/assets/javascripts/discourse/app/components/topic-list/item.gjs index ae3b44cb6b5..cd18330c1dd 100644 --- a/app/assets/javascripts/discourse/app/components/topic-list/item.gjs +++ b/app/assets/javascripts/discourse/app/components/topic-list/item.gjs @@ -166,15 +166,6 @@ export default class Item extends Component { this.navigateToTopic(this.args.topic, this.args.topic.lastUnreadUrl); return; } - - if ( - e.target.classList.contains("d-icon-thumbtack") && - e.target.closest("a.topic-status") - ) { - e.preventDefault(); - this.args.topic.togglePinnedForUser(); - return; - } } @action diff --git a/spec/system/topic_list/glimmer_spec.rb b/spec/system/topic_list/glimmer_spec.rb index c29881f8757..40a8e35bd9d 100644 --- a/spec/system/topic_list/glimmer_spec.rb +++ b/spec/system/topic_list/glimmer_spec.rb @@ -128,4 +128,17 @@ describe "glimmer topic list", type: :system do end end end + + it "unpins globally pinned topics on click" do + topic = Fabricate(:topic, pinned_globally: true, pinned_at: Time.current) + visit("/latest") + + expect(page).to have_css(".topic-list-item .d-icon-thumbtack:not(.unpinned)") + + find(".topic-list-item .d-icon-thumbtack").click + expect(page).to have_css(".topic-list-item .d-icon-thumbtack.unpinned") + + wait_for { TopicUser.exists?(topic:, user:) } + expect(TopicUser.find_by(topic:, user:).cleared_pinned_at).to_not be_nil + end end