mirror of
https://github.com/discourse/discourse-user-card-directory.git
synced 2025-06-14 10:52:10 +00:00
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:
parent
63f9de0119
commit
5f12e99dd2
@ -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,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user