Skip to content

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

DEV: Fix Ember inspector error on anonymous user (#24042)

Penar Musaraj0934cc6ece19
diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js
index 823cd31cea6..ef1493cdce2 100644
--- a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js
+++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js
@@ -34,7 +34,7 @@ export default class MyPostsSectionLink extends BaseSectionLink {
}
get showCount() {
- return this.currentUser.sidebarShowCountOfNewItems;
+ return this.currentUser?.sidebarShowCountOfNewItems;
}
get name() {
diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/review-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/review-section-link.js
index 395bafacef7..75598e571d9 100644
--- a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/review-section-link.js
+++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/review-section-link.js
@@ -28,7 +28,7 @@ export default class ReviewSectionLink extends BaseSectionLink {
get badgeText() {
// force a tracker for reviewable_count by using .get to ensure badgeText
// rerenders when reviewable_count changes
- if (this.currentUser.get("reviewable_count") > 0) {
+ if (this.currentUser?.get("reviewable_count") > 0) {
return I18n.t("sidebar.sections.community.links.review.pending_count", {
count: this.currentUser.reviewable_count,
});