إخفاء الفئات الفرعية دون إخفاء مواضيعها في قائمة المواضيع؟

نعم، كانت هناك مشكلة في طريقة تعيين الفئة التي لم أنتبه لها محليًا. قمت بتعديل المقطع أعلاه، ويجب أن يعمل الآن.

المقطع أعلاه يسمح لك بتعيين الفئات التي تريد أن يعمل عليها. إذا أردت أن يعمل على جميع الفئات، يمكنك استخدام شيء مثل هذا.

<script type="text/discourse-plugin" version="0.8">
  const { on } = require("discourse-common/utils/decorators");

  const useParentCategory = function () {
    const parentCategory = this.attrs.topic.category.parentCategory;

    if (parentCategory) {
     this.attrs.topic.set("category", parentCategory);
    }
  };

  api.modifyClass("component:topic-list-item", {
    @on("didReceiveAttrs")
    setCategory() {
      useParentCategory.call(this);
    }
  });

  api.modifyClass("component:latest-topic-list-item", {
    @on("didReceiveAttrs")
    setCategory() {
      useParentCategory.call(this);
    }
  });
</script>