DEV: Update modifyClass calls to native class syntax (#656)

This commit is contained in:
David Taylor 2024-12-02 13:22:35 +00:00 committed by GitHub
parent 6f682acae3
commit b8d50e9675
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 17 deletions

View File

@ -5,24 +5,27 @@ export default {
name: "disable-sort",
initialize() {
withPluginApi("0.8", (api) => {
api.modifyClass("component:topic-list", {
pluginId: "discourse-calendar",
@discourseComputed(
"category",
"siteSettings.disable_resorting_on_categories_enabled"
)
sortable(category, disable_resorting_on_categories_enabled) {
let disableSort = false;
if (
disable_resorting_on_categories_enabled &&
category?.custom_fields
) {
disableSort = !!category.custom_fields["disable_topic_resorting"];
api.modifyClass(
"component:topic-list",
(Superclass) =>
class extends Superclass {
@discourseComputed(
"category",
"siteSettings.disable_resorting_on_categories_enabled"
)
sortable(category, disable_resorting_on_categories_enabled) {
let disableSort = false;
if (
disable_resorting_on_categories_enabled &&
category?.custom_fields
) {
disableSort =
!!category.custom_fields["disable_topic_resorting"];
}
return !!this.changeSort && !disableSort;
}
}
return !!this.changeSort && !disableSort;
},
});
);
});
},
};