隐藏被忽略用户的帖子列表的潜在方法?

Is that possible to make an API call to get ther user’s ignored users list and hide the topic which has that user-id or remove thoes topics before the topic list was rendered?

1 个赞

Here is my implenetment for now

Inspired by
https://meta.discourse.org/t/topics-created-by-ignored-users-showing-on-homepage/170366/14
And with this theme component

It will also work on mobile.

In additional, if you update this line

to

<a href="{{topic.lastPostUrl}}" data-user-card="{{topic.last_poster_username}}" data-user-id="{{topic.creator.username}}">{{avatar topic.lastPosterUser imageSize="large"}}</a>

and change my code on
https://github.com/notedboi/Discourse-Hide-Ignored-Users/blob/main/common/head_tag.html#L13
to

  let tr = $('*[data-user-id="' + ignored[u] + '"]');

You will be able to keep the last poster’s avatar/card view while remove topic by creator.

My only concern is the script keep checking every 500ms and might take too much memory

3 个赞

I’m also looking at how to remove the ignored users from mobile category topic.

<script type="text/x-handlebars" data-template-name="components/mobile-category-topic">
<td class="main-link" data-user-id="{{topic.creator.username}}">
  <div class="topic-inset" >
    {{raw "topic-status" topic=topic}}
    {{topic-link topic}}
    {{#if topic.unseen}}
      <span class="badge-notification new-topic"></span>
    {{/if}}
    <span class={{cold-age-class topic.last_posted_at}} title={{raw-date topic.last_posted_at}}>{{format-age topic.last_posted_at}}</span>
  </div>
</td>
<td class="num posts">{{raw "list/post-count-or-badges" topic=topic postBadgesEnabled="true"}}</td>
</script>

And when I tried to add data-user-id to this view, it doesn’t work, am i looking in to a wrong template?


update: I see the issue, the topic object passed from category.topic doesn’t contain topic creator’s id, also none of the properties in the topic object can be used as flag to remove topic, I’m blocked. Any help will be appreciated :rofl:!

1 个赞

Im trying to update it and avoid using setinterval, but in case if anyone would like to use it, the last update supports both Topic Thumbnails and Topic List Excerpts

您的代码似乎不起作用,并且导致论坛运行非常缓慢。有什么想法吗?@th21

也许它太旧了,无法使用,我做了一个新组件,如果您想尝试的话。\n\nhttps://github.com/notedboi/discourse-ignore-plus\n\n它基于\nhttps://meta.discourse.org/t/need-help-finding-why-topic-list-not-updating-after-click-new-topic-reply-alert/215036

2 个赞

我使用您的组件已经很长时间了,我认为它应该成为 Discourse 核心的一部分,非常感谢您的创造。不幸的是,它现在被标记出来,因为它需要更新以兼容新的 Glimmer 主题列表:

我会看一下

2 个赞