From cb86c5ae1ebec26eb8b1627525d1d12166cbdbfb Mon Sep 17 00:00:00 2001 From: Misaka 0x4e21 Date: Mon, 2 Jul 2018 15:34:09 +0800 Subject: [PATCH] FIX: Fix badge count of other users. (#6016) Don't count the current user in "Others with this badge". --- .../javascripts/discourse/controllers/badges/show.js.es6 | 5 +++++ app/assets/javascripts/discourse/templates/badges/show.hbs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/badges/show.js.es6 b/app/assets/javascripts/discourse/controllers/badges/show.js.es6 index 2d8338963b3..a5273c253b1 100644 --- a/app/assets/javascripts/discourse/controllers/badges/show.js.es6 +++ b/app/assets/javascripts/discourse/controllers/badges/show.js.es6 @@ -28,6 +28,11 @@ export default Ember.Controller.extend(BadgeSelectController, { return username ? userCount : modelCount; }, + @computed("model.grant_count", "userBadges.grant_count") + othersCount(modelCount, userCount) { + return modelCount - userCount; + }, + @computed("model.allow_title", "model.has_badge", "model") canSelectTitle(hasTitleBadges, hasBadge) { return this.siteSettings.enable_badges && hasTitleBadges && hasBadge; diff --git a/app/assets/javascripts/discourse/templates/badges/show.hbs b/app/assets/javascripts/discourse/templates/badges/show.hbs index 952bac8b4f8..b586e4f379e 100644 --- a/app/assets/javascripts/discourse/templates/badges/show.hbs +++ b/app/assets/javascripts/discourse/templates/badges/show.hbs @@ -52,7 +52,7 @@ {{#unless canLoadMore}} {{#if canShowOthers}}
- {{i18n 'badges.others_count' count=model.grant_count}} + {{i18n 'badges.others_count' count=othersCount}}
{{/if}} {{/unless}}