diff --git a/app/assets/javascripts/discourse/app/components/quote-button.js b/app/assets/javascripts/discourse/app/components/quote-button.js index 1672857343..c8bd98576b 100644 --- a/app/assets/javascripts/discourse/app/components/quote-button.js +++ b/app/assets/javascripts/discourse/app/components/quote-button.js @@ -12,6 +12,7 @@ import { INPUT_DELAY } from "discourse-common/config/environment"; import { action } from "@ember/object"; import discourseComputed from "discourse-common/utils/decorators"; import Sharing from "discourse/lib/sharing"; +import { alias } from "@ember/object/computed"; function getQuoteTitle(element) { const titleEl = element.querySelector(".title"); @@ -23,6 +24,7 @@ export default Component.extend({ classNames: ["quote-button"], classNameBindings: ["visible"], visible: false, + privateCategory: alias("topic.category.read_restricted"), _isMouseDown: false, _reselected: false, @@ -209,14 +211,16 @@ export default Component.extend({ .off("selectionchange.quote-button"); }, - @discourseComputed - quoteSharingEnabled() { + @discourseComputed("topic.{isPrivateMessage,invisible,category}") + quoteSharingEnabled(topic) { if ( this.site.mobileView || this.siteSettings.share_quote_visibility === "none" || - this.quoteSharingSources.length === 0 || (this.currentUser && - this.siteSettings.share_quote_visibility === "anonymous") + this.siteSettings.share_quote_visibility === "anonymous") || + this.quoteSharingSources.length === 0 || + this.privateCategory || + (this.currentUser && topic.invisible) ) { return false; } @@ -232,7 +236,7 @@ export default Component.extend({ ); }, - @discourseComputed + @discourseComputed("topic.{isPrivateMessage,invisible,category}") quoteSharingShowLabel() { return this.quoteSharingSources.length > 1; }, diff --git a/app/assets/javascripts/discourse/app/components/share-panel.js b/app/assets/javascripts/discourse/app/components/share-panel.js index 74608dbfa8..abfad8adb3 100644 --- a/app/assets/javascripts/discourse/app/components/share-panel.js +++ b/app/assets/javascripts/discourse/app/components/share-panel.js @@ -9,14 +9,17 @@ import { later } from "@ember/runloop"; export default Component.extend({ tagName: null, - type: alias("panel.model.type"), - topic: alias("panel.model.topic"), + privateCategory: alias("panel.model.topic.category.read_restricted"), - @discourseComputed("topic.isPrivateMessage") - sources(isPM) { - const privateContext = this.siteSettings.login_required || isPM; + @discourseComputed("topic.{isPrivateMessage,invisible,category}") + sources(topic) { + const privateContext = + this.siteSettings.login_required || + topic.isPrivateMessage || + topic.invisible || + this.privateCategory; return Sharing.activeSources(this.siteSettings.share_links, privateContext); }, diff --git a/app/assets/javascripts/discourse/app/components/share-popup.js b/app/assets/javascripts/discourse/app/components/share-popup.js index 9564c29dd0..5c213f01f5 100644 --- a/app/assets/javascripts/discourse/app/components/share-popup.js +++ b/app/assets/javascripts/discourse/app/components/share-popup.js @@ -7,16 +7,23 @@ import { longDateNoYear } from "discourse/lib/formatter"; import discourseComputed, { on } from "discourse-common/utils/decorators"; import Sharing from "discourse/lib/sharing"; import { nativeShare } from "discourse/lib/pwa-utils"; +import { alias } from "@ember/object/computed"; export default Component.extend({ elementId: "share-link", classNameBindings: ["visible"], link: null, visible: null, + privateCategory: alias("topic.category.read_restricted"), + + @discourseComputed("topic.{isPrivateMessage,invisible,category}") + sources(topic) { + const privateContext = + this.siteSettings.login_required || + topic.isPrivateMessage || + topic.invisible || + this.privateCategory; - @discourseComputed("topic.isPrivateMessage") - sources(isPM) { - const privateContext = this.siteSettings.login_required || isPM; return Sharing.activeSources(this.siteSettings.share_links, privateContext); },