1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 08:27:42 +02:00

feat: make it easier to add content after the first post (#4050)

This commit is contained in:
IanM
2024-09-30 11:43:40 +01:00
committed by GitHub
parent 9bc8c7de99
commit e3d07cb8cc

View File

@@ -78,11 +78,24 @@ export default class PostStream extends Component {
content = <PostLoading />;
}
return (
const postStreamElement = (
<div className="PostStream-item" {...attrs}>
{content}
</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]) {
@@ -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>}
*/