mirror of
https://github.com/flarum/framework.git
synced 2025-05-23 15:19:56 +08:00
Add init hook as a way to effectively monkey patch constructors
Related to #246
This commit is contained in:
@ -71,7 +71,7 @@ export default class UserPage extends Page {
|
||||
* @param {User} user
|
||||
* @protected
|
||||
*/
|
||||
init(user) {
|
||||
show(user) {
|
||||
this.user = user;
|
||||
|
||||
app.setTitle(user.username());
|
||||
@ -90,13 +90,13 @@ export default class UserPage extends Page {
|
||||
|
||||
app.store.all('users').some(user => {
|
||||
if (user.username().toLowerCase() === lowercaseUsername && user.joinTime()) {
|
||||
this.init(user);
|
||||
this.show(user);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.user) {
|
||||
app.store.find('users', username).then(this.init.bind(this));
|
||||
app.store.find('users', username).then(this.show.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user