FIX: Topics with muted tag didn't show up when filtering by category and tag

It also removes the redundant `filter` parameter. Previously URLs looked like this:

```
http://example.com/tags/c/some-category/muted-tag/l/latest.json?filter=tags/c/some-category/muted-tag/l/latest
```

But it looks like the `filter` parameter was only used to find out if topics with a muted tag should be removed or not. But the same thing can be accomplished by using the first tag ID. The following URL looks a lot cleaner.

```
http://example.com/tags/c/some-category/muted-tag/l/latest.json
```
This commit is contained in:
Gerhard Schlager
2019-09-06 18:12:13 +02:00
parent 6bbd83067d
commit 631315624d
3 changed files with 64 additions and 39 deletions

View File

@@ -863,6 +863,7 @@ class TopicQuery
list
end
def remove_muted_categories(list, user, opts = nil)
category_id = get_category_id(opts[:exclude]) if opts
@@ -885,6 +886,7 @@ class TopicQuery
list
end
def remove_muted_tags(list, user, opts = nil)
if user.nil? || !SiteSetting.tagging_enabled || SiteSetting.remove_muted_tags_from_latest == 'never'
return list
@@ -895,16 +897,9 @@ class TopicQuery
return list
end
showing_tag = if opts[:filter]
f = opts[:filter].split('/')
f[0] == 'tags' ? f[1] : nil
else
nil
end
# if viewing the topic list for a muted tag, show all the topics
if showing_tag.present? && TagUser.lookup(user, :muted).joins(:tag).where('tags.name = ?', showing_tag).exists?
return list
if !opts[:no_tags] && opts[:tags].present?
return list if TagUser.lookup(user, :muted).joins(:tag).where('tags.name = ?', opts[:tags].first).exists?
end
if SiteSetting.remove_muted_tags_from_latest == 'always'