mirror of
https://github.com/flarum/core.git
synced 2025-08-04 15:37:51 +02:00
common: rework Component#render again to simplify substite m(class, props)
Can be used instead of m(DiscussionList, app.cache.discussionList.props), for example - it's now app.cache.discussionList.render()
This commit is contained in:
@@ -65,18 +65,7 @@ export default class Component<T extends ComponentProps = any> implements ClassC
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return m.fragment(
|
return m(this.constructor, this.props);
|
||||||
{
|
|
||||||
...this.props,
|
|
||||||
oninit: (...args) => this.oninit(...args),
|
|
||||||
oncreate: (...args) => this.oncreate(...args),
|
|
||||||
onbeforeupdate: (...args) => this.onbeforeupdate(...args),
|
|
||||||
onupdate: (...args) => this.onupdate.bind(...args),
|
|
||||||
onbeforeremove: (...args) => this.onbeforeremove.bind(...args),
|
|
||||||
onremove: (...args) => this.onremove.bind(...args),
|
|
||||||
},
|
|
||||||
this.view()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static component(props: ComponentProps | any = {}, children?: Mithril.Children) {
|
static component(props: ComponentProps | any = {}, children?: Mithril.Children) {
|
||||||
|
@@ -20,7 +20,7 @@ export default class CommentPost extends Post {
|
|||||||
*/
|
*/
|
||||||
revealContent: boolean = false;
|
revealContent: boolean = false;
|
||||||
|
|
||||||
postUser: Vnode<{}, PostUser>;
|
postUser!: Vnode<{}, PostUser>;
|
||||||
|
|
||||||
oninit(vnode) {
|
oninit(vnode) {
|
||||||
super.oninit(vnode);
|
super.oninit(vnode);
|
||||||
|
@@ -76,7 +76,7 @@ export default class IndexPage extends Page {
|
|||||||
view() {
|
view() {
|
||||||
if (!app.cache.discussionList) return;
|
if (!app.cache.discussionList) return;
|
||||||
|
|
||||||
const discussionList = m(DiscussionList, app.cache.discussionList.props);
|
const discussionList = app.cache.discussionList.render();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="IndexPage">
|
<div className="IndexPage">
|
||||||
|
@@ -15,7 +15,7 @@ export type NotificationItem = {
|
|||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The icon to display in the column header/notificatio grid row.
|
* The icon to display in the column header/notification grid row.
|
||||||
*/
|
*/
|
||||||
icon: string;
|
icon: string;
|
||||||
|
|
||||||
@@ -60,6 +60,7 @@ export default class NotificationGrid extends Component<NotificationGridProps> {
|
|||||||
state: !!preference,
|
state: !!preference,
|
||||||
disabled: typeof preference === 'undefined',
|
disabled: typeof preference === 'undefined',
|
||||||
onchange: () => this.toggle([key]),
|
onchange: () => this.toggle([key]),
|
||||||
|
oninit: vnode => (this.inputs[key] = vnode.state),
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user