DEV: Upgrade modifyClass syntax to remove object-literal decorators (#50)

Decorators on object literal properties are unsupported in most modern JS tooling, including ts/glint and Prettier 3.0. Using the new native-class-based modifyClass syntax means we can use decorators safely
This commit is contained in:
David Taylor 2025-03-05 10:36:25 +00:00 committed by GitHub
parent 63f9de0119
commit 5f12e99dd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,14 +42,14 @@ export default {
},
});
api.modifyClass("controller:users", {
pluginId: "user-card-directory",
cachedUserCardInfo: null,
api.modifyClass(
"controller:users",
(Superclass) =>
class extends Superclass {
init() {
this.set("cachedUserCardInfo", {});
this._super(...arguments);
},
super.init(...arguments);
}
@discourseComputed("model.content.@each")
userCards(allUsers) {
@ -82,7 +82,9 @@ export default {
while (toLoad.length > 0) {
const thisBatch = toLoad.splice(0, loadMax);
const promise = ajax("/user-cards.json", {
data: { user_ids: thisBatch.map((uc) => uc.user.id).join(",") },
data: {
user_ids: thisBatch.map((uc) => uc.user.id).join(","),
},
});
thisBatch.forEach((uc) => {
// Each user card expects its own promise
@ -102,12 +104,12 @@ export default {
}
return userCardInfos;
},
}
@action
userCardShowUser(user) {
DiscourseURL.routeTo(userPath(user.username_lower));
},
}
@action
updateOrder(field, asc) {
@ -115,8 +117,9 @@ export default {
order: field,
asc,
});
},
});
}
}
);
});
},
};