Skip to content

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

FIX: Correctly display group unread indicator in gjs (#30302)

Jarek Radosze03121c55b26
diff --git a/app/assets/javascripts/discourse/app/components/topic-list/unread-indicator.gjs b/app/assets/javascripts/discourse/app/components/topic-list/unread-indicator.gjs
index adacb8611ab..79866942fc4 100644
--- a/app/assets/javascripts/discourse/app/components/topic-list/unread-indicator.gjs
+++ b/app/assets/javascripts/discourse/app/components/topic-list/unread-indicator.gjs
@@ -26,12 +26,8 @@ export default class UnreadIndicator extends Component {
return `/private-messages/unread-indicator/${this.args.topic.id}`;
}
- get isUnread() {
- return typeof this.args.topic.get("unread_by_group_member") !== "undefined";
- }
-
<template>
- {{~#if this.isUnread~}}
+ {{~#if @topic.unread_by_group_member~}}
&nbsp;<span
title={{i18n "topic.unread_indicator"}}
class="badge badge-notification unread-indicator"
diff --git a/app/assets/javascripts/discourse/tests/integration/components/topic-list-item-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/topic-list-item-test.gjs
index 91dbb1eeb2d..facc422ddb1 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/topic-list-item-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/topic-list-item-test.gjs
@@ -1,6 +1,7 @@
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import TopicListItem from "discourse/components/topic-list/item";
+import TopicList from "discourse/components/topic-list/list";
import HbrTopicListItem from "discourse/components/topic-list-item";
import { withPluginApi } from "discourse/lib/plugin-api";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
@@ -58,4 +59,28 @@ module("Integration | Component | topic-list-item", function (hooks) {
.dom(".topic-list-item[data-topic-id='1235']")
.doesNotHaveClass("bar");
});
+
+ test("shows unread-by-group-member indicator", async function (assert) {
+ const store = this.owner.lookup("service:store");
+ const topics = [
+ store.createRecord("topic", { id: 1234 }),
+ store.createRecord("topic", {
+ id: 1235,
+ unread_by_group_member: true,
+ }),
+ store.createRecord("topic", {
+ id: 1236,
+ unread_by_group_member: false,
+ }),
+ ];
+
+ await render(<template><TopicList @topics={{topics}} /></template>);
+
+ assert
+ .dom(".badge.badge-notification.unread-indicator")
+ .exists({ count: 1 });
+ assert
+ .dom(".topic-list-item[data-topic-id='1235'] .unread-indicator")
+ .exists();
+ });
});