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

This commit is contained in:
Jarek Radosz 2024-12-16 20:50:49 +01:00 committed by GitHub
parent 03bb43f746
commit e03121c55b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 5 deletions

View File

@ -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"

View File

@ -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();
});
});