FIX: bug with sharing when used outside a topic

FIX: bug with sharing when used outside a topic

Followup to ac76bfb, fixes share buttons in topic lists (only used in themes or plugins)

diff --git a/app/assets/javascripts/discourse/app/components/share-panel.js b/app/assets/javascripts/discourse/app/components/share-panel.js
index abfad8a..ad9ffa7 100644
--- a/app/assets/javascripts/discourse/app/components/share-panel.js
+++ b/app/assets/javascripts/discourse/app/components/share-panel.js
@@ -17,8 +17,8 @@ export default Component.extend({
   sources(topic) {
     const privateContext =
       this.siteSettings.login_required ||
-      topic.isPrivateMessage ||
-      topic.invisible ||
+      (topic && topic.isPrivateMessage) ||
+      (topic && 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 5c213f0..7668f1f 100644
--- a/app/assets/javascripts/discourse/app/components/share-popup.js
+++ b/app/assets/javascripts/discourse/app/components/share-popup.js
@@ -20,8 +20,8 @@ export default Component.extend({
   sources(topic) {
     const privateContext =
       this.siteSettings.login_required ||
-      topic.isPrivateMessage ||
-      topic.invisible ||
+      (topic && topic.isPrivateMessage) ||
+      (topic && topic.invisible) ||
       this.privateCategory;
 
     return Sharing.activeSources(this.siteSettings.share_links, privateContext);

GitHub sha: 52b864fa