mirror of
https://github.com/flarum/core.git
synced 2025-08-08 01:16:52 +02:00
feat: make it easier to add content after the first post (#4050)
This commit is contained in:
@@ -78,11 +78,24 @@ export default class PostStream extends Component {
|
|||||||
content = <PostLoading />;
|
content = <PostLoading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
const postStreamElement = (
|
||||||
<div className="PostStream-item" {...attrs}>
|
<div className="PostStream-item" {...attrs}>
|
||||||
{content}
|
{content}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If we're on the first post, call the afterFirstPostItems method and add any additional elements.
|
||||||
|
if (i === 0 && this.afterFirstPostItems().toArray().length > 0) {
|
||||||
|
// Using m.fragment to return multiple elements without an enclosing container
|
||||||
|
return m.fragment({ ...attrs }, [
|
||||||
|
postStreamElement,
|
||||||
|
<div className="PostStream-item PostStream-afterFirstPost" key="afterFirstPost">
|
||||||
|
{this.afterFirstPostItems().toArray()}
|
||||||
|
</div>,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return postStreamElement;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!viewingEnd && posts[this.stream.visibleEnd - this.stream.visibleStart - 1]) {
|
if (!viewingEnd && posts[this.stream.visibleEnd - this.stream.visibleStart - 1]) {
|
||||||
@@ -117,6 +130,15 @@ export default class PostStream extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {ItemList<import('mithril').Children>}
|
||||||
|
*/
|
||||||
|
afterFirstPostItems() {
|
||||||
|
const items = new ItemList();
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {ItemList<import('mithril').Children>}
|
* @returns {ItemList<import('mithril').Children>}
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user