mirror of
https://github.com/discourse/discourse-user-card-directory.git
synced 2025-06-22 06:22:11 +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", {
|
api.modifyClass(
|
||||||
pluginId: "user-card-directory",
|
"controller:users",
|
||||||
cachedUserCardInfo: null,
|
(Superclass) =>
|
||||||
|
class extends Superclass {
|
||||||
init() {
|
init() {
|
||||||
this.set("cachedUserCardInfo", {});
|
this.set("cachedUserCardInfo", {});
|
||||||
this._super(...arguments);
|
super.init(...arguments);
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("model.content.@each")
|
@discourseComputed("model.content.@each")
|
||||||
userCards(allUsers) {
|
userCards(allUsers) {
|
||||||
@ -82,7 +82,9 @@ export default {
|
|||||||
while (toLoad.length > 0) {
|
while (toLoad.length > 0) {
|
||||||
const thisBatch = toLoad.splice(0, loadMax);
|
const thisBatch = toLoad.splice(0, loadMax);
|
||||||
const promise = ajax("/user-cards.json", {
|
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) => {
|
thisBatch.forEach((uc) => {
|
||||||
// Each user card expects its own promise
|
// Each user card expects its own promise
|
||||||
@ -102,12 +104,12 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return userCardInfos;
|
return userCardInfos;
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
userCardShowUser(user) {
|
userCardShowUser(user) {
|
||||||
DiscourseURL.routeTo(userPath(user.username_lower));
|
DiscourseURL.routeTo(userPath(user.username_lower));
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updateOrder(field, asc) {
|
updateOrder(field, asc) {
|
||||||
@ -115,8 +117,9 @@ export default {
|
|||||||
order: field,
|
order: field,
|
||||||
asc,
|
asc,
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user