Skip to content

Commit 9941be3

Browse files
authored
FIX: Use the code TopicLink component. (#86)
Instead of generating the topic link manually, using the core `TopicLink` component lets us offload the URL-building logic to core, instead.
1 parent b52439f commit 9941be3

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

.discourse-compatibility

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<= 3.5.0.beta9-dev: b52439ff8c4b7629a693a9b2d9546c15678c7a8a
12
< 3.5.0.beta5-dev: f4ef4a41587d75d062b4fc7841d8f78e7726ea59
23
< 3.5.0.beta1-dev: 5fda8d63def631692e8780c6b8bc2457eae55a29
34
< 3.4.0.beta1-dev: 471a797e05f9b55df90ef71145420ec001f9f48d

javascripts/discourse/components/category-topics.gjs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import Component from "@glimmer/component";
22
import { tracked } from "@glimmer/tracking";
33
import { service } from "@ember/service";
4+
import TopicLink from "discourse/components/topic-list/topic-link";
45
import categoryLink from "discourse/helpers/category-link";
5-
import htmlSafe from "discourse/helpers/html-safe";
6-
import replaceEmoji from "discourse/helpers/replace-emoji";
7-
import getURL from "discourse/lib/get-url";
86
import Category from "discourse/models/category";
97

108
export default class CategoryTopics extends Component {
@@ -26,16 +24,7 @@ export default class CategoryTopics extends Component {
2624
this.category = Category.findById(categoryId);
2725

2826
this.store.findFiltered("topicList", { filter }).then((result) => {
29-
const results = result.topic_list.topics;
30-
31-
results.forEach((topic) => {
32-
topic.url = `${getURL("/t/")}${topic.slug}/${topic.id}`;
33-
if (topic.last_read_post_number > 0) {
34-
topic.url += `/${topic.last_read_post_number}`;
35-
}
36-
});
37-
38-
this.topics = results.slice(0, count);
27+
this.topics = result.topics.slice(0, count);
3928
});
4029
}
4130

@@ -49,12 +38,11 @@ export default class CategoryTopics extends Component {
4938

5039
<div class="category-topics--content">
5140
{{#each this.topics as |topic|}}
52-
<a href={{topic.url}} class="category-topics--topic">
53-
{{htmlSafe (replaceEmoji topic.fancy_title)}}
41+
<TopicLink @topic={{topic}} class="category-topics--topic">
5442
<span class="category-topics--posts-count">
5543
({{topic.posts_count}})
5644
</span>
57-
</a>
45+
</TopicLink>
5846
{{/each}}
5947
</div>
6048
</template>

0 commit comments

Comments
 (0)