DEV: Remove dead code (`latestTopicOnly`) (#11833)

Background: I wanted to see `categories.latest_by` translation in context in a live app but couldn't find it, so I traced it throughout the code.

My step-by-step reasoning for the removal is:

1. `categories-only` does not use `latestTopicOnly`, so there's no need to call it with that argument
2. `parent-category-row` is never called with `latestTopicOnly` argument, so the reference to that arg can be removed from its template
3. after that, `featured-topic` is now no longer ever called with `latestTopicOnly` argument (except in the `ghost` theme, but that's because its override of `categories-only` template 4e2fba963c/common/header.html (L119) is based on the old version of that template from core), so it seems safe to remove it there too (`categories.latest_by` i18n string is also no longer needed)
4. then, nothing is using `latestTopicOnly` anymore so it can be removed from `categories` hbs/js

I checked in each step that there are no plugins or themes (in all-the-plugins/all-the-themes) using those properties/arguments/strings.
This commit is contained in:
Jarek Radosz 2021-01-28 11:48:51 +01:00 committed by GitHub
parent 5a6baa7c46
commit 8881ae4af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 2 additions and 23 deletions

View File

@ -19,15 +19,6 @@ export default DiscoveryController.extend({
canEdit: reads("currentUser.staff"), canEdit: reads("currentUser.staff"),
@discourseComputed("model.categories.[].featuredTopics.length")
latestTopicOnly() {
return (
this.get("model.categories").find(
(c) => c.get("featuredTopics.length") > 1
) === undefined
);
},
@discourseComputed("model.parentCategory") @discourseComputed("model.parentCategory")
categoryPageStyle(parentCategory) { categoryPageStyle(parentCategory) {
let style = this.site.mobileView let style = this.site.mobileView

View File

@ -1,3 +1,2 @@
{{categories-only categories=categories {{categories-only categories=categories
latestTopicOnly=latestTopicOnly
showTopics="true"}} showTopics="true"}}

View File

@ -2,11 +2,4 @@
<a href={{topic.lastUnreadUrl}} class="title">{{html-safe topic.fancyTitle}}</a> <a href={{topic.lastUnreadUrl}} class="title">{{html-safe topic.fancyTitle}}</a>
{{topic-post-badges newPosts=topic.totalUnread unseen=topic.unseen url=topic.lastUnreadUrl}} {{topic-post-badges newPosts=topic.totalUnread unseen=topic.unseen url=topic.lastUnreadUrl}}
{{#if latestTopicOnly}} <a href={{topic.lastPostUrl}} class="last-posted-at">{{format-age topic.last_posted_at}}</a>
<div class="last-user-info">
{{i18n "categories.latest_by"}} <a href={{html-safe topic.lastPosterUrl}}>{{topic.last_poster.username}}</a>
<a href={{topic.lastPostUrl}}>{{format-age topic.last_posted_at}}</a>
</div>
{{else}}
<a href={{topic.lastPostUrl}} class="last-posted-at">{{format-age topic.last_posted_at}}</a>
{{/if}}

View File

@ -32,7 +32,7 @@
{{#if showTopics}} {{#if showTopics}}
<td class="latest"> <td class="latest">
{{#each category.featuredTopics as |t|}} {{#each category.featuredTopics as |t|}}
{{featured-topic topic=t latestTopicOnly=latestTopicOnly}} {{featured-topic topic=t}}
{{/each}} {{/each}}
</td> </td>
{{/if}} {{/if}}

View File

@ -1,6 +1,5 @@
{{#discovery-categories refresh=(action "refresh")}} {{#discovery-categories refresh=(action "refresh")}}
{{component categoryPageStyle {{component categoryPageStyle
categories=model.categories categories=model.categories
latestTopicOnly=latestTopicOnly
topics=model.topics}} topics=model.topics}}
{{/discovery-categories}} {{/discovery-categories}}

View File

@ -1,3 +1,2 @@
{{categories-only categories=categories {{categories-only categories=categories
latestTopicOnly=latestTopicOnly
showTopics="true"}} showTopics="true"}}

View File

@ -1,6 +1,5 @@
{{#discovery-categories refresh=(action "refresh")}} {{#discovery-categories refresh=(action "refresh")}}
{{component categoryPageStyle {{component categoryPageStyle
categories=model.categories categories=model.categories
latestTopicOnly=latestTopicOnly
topics=model.topics}} topics=model.topics}}
{{/discovery-categories}} {{/discovery-categories}}

View File

@ -838,7 +838,6 @@ en:
posts: "Posts" posts: "Posts"
topics: "Topics" topics: "Topics"
latest: "Latest" latest: "Latest"
latest_by: "latest by"
toggle_ordering: "toggle ordering control" toggle_ordering: "toggle ordering control"
subcategories: "Subcategories" subcategories: "Subcategories"
muted: "Muted categories" muted: "Muted categories"