From 2bcbabc087ee08308a14131a4e9d2d50307759e7 Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Mon, 24 Apr 2023 07:33:09 +0300 Subject: [PATCH] FIX: Include liked_consolidated and reaction types in the likes tab unread count (#21198) --- .../app/components/user-menu/menu.js | 6 +++++- .../components/user-menu/menu-test.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/components/user-menu/menu.js b/app/assets/javascripts/discourse/app/components/user-menu/menu.js index 1b4abeecb2d..c2d1b367644 100644 --- a/app/assets/javascripts/discourse/app/components/user-menu/menu.js +++ b/app/assets/javascripts/discourse/app/components/user-menu/menu.js @@ -63,7 +63,11 @@ const CORE_TOP_TABS = [ } get count() { - return this.getUnreadCountForType("liked"); + return ( + this.getUnreadCountForType("liked") + + this.getUnreadCountForType("liked_consolidated") + + this.getUnreadCountForType("reaction") + ); } // TODO(osama): reaction is a type used by the reactions plugin, but it's diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-test.js index 36026d25119..046c1627e96 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-test.js @@ -303,4 +303,23 @@ module("Integration | Component | user-menu", function (hooks) { ); assert.strictEqual(queryAll("#quick-access-review-queue ul li").length, 8); }); + + test("count on the likes tab", async function (assert) { + this.currentUser.set("grouped_unread_notifications", { + [NOTIFICATION_TYPES.liked]: 1, + [NOTIFICATION_TYPES.liked_consolidated]: 2, + [NOTIFICATION_TYPES.reaction]: 3, + [NOTIFICATION_TYPES.bookmark_reminder]: 10, + }); + await render(template); + + const likesCountBadge = query( + "#user-menu-button-likes .badge-notification" + ); + assert.strictEqual( + likesCountBadge.textContent, + (1 + 2 + 3).toString(), + "combines unread counts for `liked`, `liked_consolidated` and `reaction` types" + ); + }); });