diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/messages-section/message-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/messages-section/message-section-link.js index a28cebdeb7..d1a10fefb0 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/user/messages-section/message-section-link.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/messages-section/message-section-link.js @@ -73,14 +73,10 @@ export default class MessageSectionLink { } get prefixType() { - if (this._isInbox) { - return "icon"; - } + return "icon"; } get prefixValue() { - if (this._isInbox) { - return "inbox"; - } + return "inbox"; } } diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/base-tag-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/base-tag-section-link.js new file mode 100644 index 0000000000..6a32ae9027 --- /dev/null +++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/base-tag-section-link.js @@ -0,0 +1,21 @@ +export default class BaseTagSectionLink { + constructor({ tagName }) { + this.tagName = tagName; + } + + get name() { + return this.tagName; + } + + get text() { + return this.tagName; + } + + get prefixType() { + return "icon"; + } + + get prefixValue() { + return "tag"; + } +} diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/pm-tag-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/pm-tag-section-link.js index fceac26abf..3c1b4ccb1b 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/pm-tag-section-link.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/pm-tag-section-link.js @@ -1,11 +1,9 @@ -export default class PMTagSectionLink { - constructor({ tagName, currentUser }) { - this.tagName = tagName; - this.currentUser = currentUser; - } +import BaseTagSectionLink from "discourse/lib/sidebar/user/tags-section/base-tag-section-link"; - get name() { - return this.tagName; +export default class PMTagSectionLink extends BaseTagSectionLink { + constructor({ currentUser }) { + super(...arguments); + this.currentUser = currentUser; } get models() { @@ -15,8 +13,4 @@ export default class PMTagSectionLink { get route() { return "userPrivateMessages.tagsShow"; } - - get text() { - return this.tagName; - } } diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/tag-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/tag-section-link.js index 85ee3ae956..094fe74de2 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/tag-section-link.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/tags-section/tag-section-link.js @@ -3,13 +3,14 @@ import I18n from "I18n"; import { tracked } from "@glimmer/tracking"; import { bind } from "discourse-common/utils/decorators"; +import BaseTagSectionLink from "discourse/lib/sidebar/user/tags-section/base-tag-section-link"; -export default class TagSectionLink { +export default class TagSectionLink extends BaseTagSectionLink { @tracked totalUnread = 0; @tracked totalNew = 0; - constructor({ tagName, topicTrackingState }) { - this.tagName = tagName; + constructor({ topicTrackingState }) { + super(...arguments); this.topicTrackingState = topicTrackingState; this.refreshCounts(); } @@ -27,10 +28,6 @@ export default class TagSectionLink { } } - get name() { - return this.tagName; - } - get models() { return [this.tagName]; } @@ -49,10 +46,6 @@ export default class TagSectionLink { return "tag.show tag.showNew tag.showUnread tag.showTop"; } - get text() { - return this.tagName; - } - get badgeText() { if (this.totalUnread > 0) { return I18n.t("sidebar.unread_count", { @@ -64,12 +57,4 @@ export default class TagSectionLink { }); } } - - get prefixType() { - return "icon"; - } - - get prefixValue() { - return "tag"; - } }